In my configuration in which I am using the failover protocol to get a
master-slave configuration. <broker1> and <broker2> are configured to point
to the same database.

Following is my code snippet to create queue sender to send the messages on
the queue.
        Properties props = new Properties();

props.setProperty("java.naming.factory.initial","org.apache.activemq.jndi.ActiveMQInitialContextFactory");
        props.setProperty("java.naming.provider.url",
"failover:(tcp://<broker1>:61616,tcp://<broker2>:61616)?timeout=3000");
        props.setProperty("queue.queue1", "wdp.queue1");

        Context ctx = new InitialContext(props);
        QueueConnectionFactory qFactory = (QueueConnectionFactory)
ctx.lookup("QueueConnectionFactory");

        QueueConnection conn = qFactory.createQueueConnection();

        //Creating a queue session
        final QueueSession session = conn.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);

        Queue queue = (Queue) ctx.lookup(queueName);

        //Creating a queue sender to send the message on the queue
        QueueSender sender = session.createSender(queue);
        
        //Invoking QueueSender.send
        sender.send(session.createTextMessage(message));
        
If I have only the broker started, the application can successfully send the
message on the queue on which the broker is active. 
Whereas if both broker1 and broker2 are started, where one broker has the
lock on the database and other is looping for the lock, the application
waits indefinately for the event to be sent by sender.send().

Am I missing some configuration in the failover protocol or need some
special setting on the brokers?

--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Unable-to-write-to-a-queue-in-a-master-slave-configuration-tp4396422p4396422.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to