Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-5460

HA : Failover does not happen with 2 AMQ instances when one runs on 32 bit another on 64 bit

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Abandoned
    • 5.10.0
    • None
    • Transport
    • RHEL 6.5, Oracle JDK 1.7, (64 bit)
      RHEL 6.x , Oracle JDK 1.7 (32 bit)

    Description

      We have two ActiveMQ(version 5.10.0) instances running and I am using the shared storage to achieve HA. However I am unable to see failover happening for the producer and consumer(s).

      ActiveMQ broker-1 runs on IP1 and broker-2 on IP2 And under the activemq.xml of configuration I have modified persistence adapter to use a shared directory which is present on IP1.

      <persistenceAdapter>
      <kahaDB directory="\\IP1\shared-directory\for activemq\data"/>
      </persistenceAdapter>
      Both in producer and consumer sides I am using following JNDI configurations to get the connections and build sessions,etc.

      jndi.properties

      java.naming.factory.initial = ..........ActiveMQInitialContextFactory
      java.naming.provider.url = failover:(tcp://IP1:61616,tcp://IP2:61616)?randomize=false
      connectionFactoryNames = myConnectionFactory
      queue.requestQ = my.RequestQ

      Interesting part is :

      When I start this broker pair, I see that one of the brokers becomes master. When I start the producer, which puts the message on the Q (say producer has put 100 messages on the Q). While my producer is still running; I shutdown master broker, hence slave broker acquires the file-lock and becomes master.When I open the webconsole I see that 100 messages are still there on the Q. Even though producer is running it no longer puts any messages on this Q.

      Similar to this for the consumers also. Consumer was picking messages from the Q, this Q has say 100 messages unconsumed when master failed, now master goes down, slave becomes master, I see 100 messages are still unconsumed, but the consumer does not pick any message from the Q.

      I waited them to failover for a long time.(>10 mins.) Can any one please suggest what configuration am I missing ?

      I am copy pasting producer and consumer as is (I've copied this from ActiveMQ in action book with minor modifications).

      Producer

      public class Producer {

      private static String brokerURL = "failover:(tcp://IP1:3389,tcp://IP2:3389)";
      private static transient ConnectionFactory factory;
      private transient Connection connection;
      private transient Session session;
      private transient MessageProducer producer;

      private static int count = 10;
      private static int total;
      private static int id = 1000000;
      private String jobs[] = new String[]

      Unknown macro: { "suspend", "delete" }

      ;

      public Producer() throws JMSException

      Unknown macro: { factory = new ActiveMQConnectionFactory(brokerURL); connection = factory.createConnection(); connection.start(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); producer = session.createProducer(null); }

      public void close() throws JMSException {
      if (connection != null)

      Unknown macro: { connection.close(); }

      }

      public static void main(String[] args) throws JMSException {
      Producer producer = new Producer();
      while (total < 1000) {
      for (int i = 0; i < count; i++)

      Unknown macro: { producer.sendMessage(); }

      total += count;
      System.out.println("Sent '" + count + "' of '" + total
      + "' job messages");
      try

      Unknown macro: { Thread.sleep(1000); }

      catch (InterruptedException x) {
      }
      }
      producer.close();

      }

      public void sendMessage() throws JMSException {
      int idx = 0;
      while (true) {
      idx = (int) Math.round(jobs.length * Math.random());
      if (idx < jobs.length)

      Unknown macro: { break; }

      }
      String job = jobs[idx];
      Destination destination = session.createQueue("JOBS." + job);
      Message message = session.createObjectMessage(id++);
      System.out.println("Sending: id: "
      + ((ObjectMessage) message).getObject() + " on queue: "
      + destination);
      producer.send(destination, message);
      }
      }

      Consumer

      public class Consumer {

      private static String brokerURL = "failover:(tcp://IP1:3389,tcp://IP2:3389)";
      private static transient ConnectionFactory factory;
      private transient Connection connection;
      private transient Session session;

      private String jobs[] = new String[]

      Unknown macro: { "suspend", "delete" }

      ;

      public Consumer() throws JMSException

      Unknown macro: { factory = new ActiveMQConnectionFactory(brokerURL); connection = factory.createConnection(); connection.start(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); }

      public void close() throws JMSException {
      if (connection != null)

      Unknown macro: { connection.close(); }

      }

      public static void main(String[] args) throws JMSException {
      Consumer consumer = new Consumer();
      for (String job : consumer.jobs)

      Unknown macro: { Destination destination = consumer.getSession().createQueue( "JOBS." + job); MessageConsumer messageConsumer = consumer.getSession() .createConsumer(destination); messageConsumer.setMessageListener(new Listener(job)); }

      }

      public Session getSession()

      Unknown macro: { return session; }

      }

      What I've observed is :
      One AMQ is running on 32 bit, another on 64 bit.
      If the producer/consumer is running on 64 bit machine, it fails over to 32 bit AMQ.
      If the producer or consumer is running on 32 bit machine it does not failover to 64 bit AMQ.

      Attachments

        Activity

          People

            Unassigned Unassigned
            arpanr Arpan Rajani
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: