activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arpan (JIRA)" <j...@apache.org>
Subject [jira] [Created] (AMQ-5460) HA : Failover does not happen with 2 AMQ instances when one runs on 32 bit another on 64 bit
Date Thu, 27 Nov 2014 07:02:12 GMT
Arpan created AMQ-5460:
--------------------------

             Summary: HA : Failover does not happen with 2 AMQ instances when one runs on
32 bit another on 64 bit
                 Key: AMQ-5460
                 URL: https://issues.apache.org/jira/browse/AMQ-5460
             Project: ActiveMQ
          Issue Type: Bug
          Components: Transport
    Affects Versions: 5.10.0
         Environment: RHEL 6.5, Oracle JDK 1.7, (64 bit)
RHEL 6.x , Oracle JDK 1.7 (32 bit)
            Reporter: Arpan
            Priority: Critical


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.

{quote}
<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.
{quote}

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

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).

{quote}
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[] { "suspend", "delete" };

    public Producer() throws JMSException {
        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) {
            connection.close();
        }
    }

    public static void main(String[] args) throws JMSException {
        Producer producer = new Producer();
        while (total < 1000) {
            for (int i = 0; i < count; i++) {
                producer.sendMessage();
            }
            total += count;
            System.out.println("Sent '" + count + "' of '" + total
                    + "' job messages");
            try {
                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) {
                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);
    }
}
{quote}

Consumer
{quote}
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[] { "suspend", "delete" };

    public Consumer() throws JMSException {
        factory = new ActiveMQConnectionFactory(brokerURL);
        connection = factory.createConnection();
        connection.start();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    }

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

    public static void main(String[] args) throws JMSException {
        Consumer consumer = new Consumer();
        for (String job : consumer.jobs) {
            Destination destination = consumer.getSession().createQueue(
                    "JOBS." + job);
            MessageConsumer messageConsumer = consumer.getSession()
                    .createConsumer(destination);
            messageConsumer.setMessageListener(new Listener(job));
        }
    }

    public Session getSession() {
        return session;
    }

}
{quote}


*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.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message