activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pompanoSlayer <>
Subject failover protocol not reconnecting to single boker
Date Wed, 08 Jun 2016 14:45:59 GMT
>From what I read, I would only need to add failover:(tcp://localhost:61616)
as the connection url for the broker and activeMQ does all the reconnecting
for me. However I can't seem to get this right. The program waits for the
broker to go online and is able to read messages out of the queue when
there's one. When I stop the broker, the program just exits.

Here's my test program.

    QueueConnectionFactory queueConnectionFactory;
    QueueConnection queueConnection;
    QueueSession queueSession;
    QueueReceiver queueReceiver;
    Queue queue;

        ActiveMQConnectionFactory connectionFactory = new

        // Create a Connection
        queueConnection = connectionFactory.createQueueConnection();
        queueSession = queueConnection.createQueueSession(false,
        queue = queueSession.createQueue("testUpdate");
        queueReceiver = queueSession.createReceiver(queue);

            message ->{
                try {
                    if(message != null) {
                        String msgText = null;
                        if (message instanceof TextMessage) {
                            msgText = ((TextMessage) message).getText();
                        } else {
                            msgText = message.toString();
                            System.out.println("message is of type " +
                        System.out.println("Message Received: " + msgText);
                } catch (JMSException jmse) {
                        System.err.println("An exception occurred: " +

I am not sure what I am missing or the failover protocol is not what I am
expecting it to do.

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message