You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by "anton.mithun" <mi...@gmail.com> on 2016/07/22 09:08:53 UTC

ActiveMQ Artemis Reconnection/Disconnect notification.

Hi,

Artemis connection setup is done during the initial bean loading. 

            connectionFactory = new
ActiveMQConnectionFactory(connectionUrl);
            connectionFactory.setReconnectAttempts(reconnectAttempts); 
            connection = connectionFactory.createConnection(username,
password);
            connection.start();
            session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
            producer = session.createProducer(null);
            connection.setExceptionListener(new FailoverListener());


private class FailoverListener implements ExceptionListener {..}

And after that I am sending messages in a irregular intervals using this
producer.

public boolean publish(Serializable message, String queueName) {
        boolean success = true;
        try {
            Queue queue = session.createQueue(queueName);
            ObjectMessage objectMessage = session.createObjectMessage();
            objectMessage.setObject(message);
            producer.send(queue, objectMessage);
            LOGGER.debug("Sent Message : " +
objectMessage.getObject().toString() + " Queue Name : " +
queue.getQueueName());
        } catch (JMSException e) {
            LOGGER.error(e.getMessage(), e);
            success = false;
        }
        return success;
    }

 The ExceptionListener will get code from the exception like   FAILOVER and
DISCONNECT. 
As I need automatic reattachment of the session I have given the option 
connectionFactory.setReconnectAttempts(reconnectAttempts); 
which will look for FAILOVER.

My problem is that I want to get notified when the server gets disconnected
as well as FAILOVER. that is to get DISCONNECT and FAILOVER . so that I can
stop publishing.
Since I have given reconnectAttempts = -1 , DISCONNECT will not be send
until reattempts are done, which are infinite attempts ! 
How can I get notified for both these events?

Thanks.




--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-Artemis-Reconnection-Disconnect-notification-tp4714293.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.