Cannot monitor Failover Transport

Previous Topic Next Topic
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view

Cannot monitor Failover Transport


I already created a JIRA  AMQ-6860
<>   for this, but I was
redirected to the forum.

When adding a TransportListener as described in  How can I monitor the
connection with the broker
, using a default failover settings and the broker being down nothing is
being sent to the listener. Is this an expected behaviour?

How can one monitor when the failover transport is not being able to
connect? Apart from looking into the warning message into the logs?

Thank you in advance,

Sent from:
Reply | Threaded
Open this post in threaded view

Re: Cannot monitor Failover Transport

Hi Filip,

First of all, you should share more details on your setup. Is it just one
broker listed within failover:(..), or more than one? Are you sure you are
registering your TransportListener properly on a client side? If you have
more than one broker for failover, and you connect to the first one, but
kill the second one, you won't get any notifications as non-connected
brokers are not monitored.

Another case you might be referencing: on initial connection attempt no
brokers available. I've double checked this and can confirm no notifications
are sent (well, TransportListener's method signatures on their own don't
speak about initial connection). In this case, you can do the following:

1) create a connection, add transport listener as needed
2) in a separate thread, monitor connection state by calling
connection#isStarted(). It will be false until the connection is

Code snippet:

ConnectionFactory connectionFactory = new
final ActiveMQConnection connection = (ActiveMQConnection)
connection.addTransportListener(new TransportListener() {
   public void onCommand(Object o) { System.out.println("OnCommand: " + o);
   public void onException(IOException e) { e.printStackTrace(); }
   public void transportInterupted() { System.out.println("Interrupted"); }
   public void transportResumed() { System.out.println("Resumed"); }

new Thread(new Runnable() {
   public void run() {
      while(true) {
         System.out.println("Connection started? : " +
         try {
         } catch (InterruptedException e) {


Sent from:
Reply | Threaded
Open this post in threaded view

Re: Cannot monitor Failover Transport

Hi,Sorry for not being more specific. I have created an example with my
setup. You can find it  here
<>  . It is a
simple spring boot application where the broker url is set to 2 failover
addresses (no ActiveMQ needs to run to see the issue).The TransportListener
is registered with the properly (I think).The issue I am experiencing is not
when a broker goes down, but when no broker is available during startup.I
know that the TransportListener method signatures don't speak about initial
connection, but I thought that monitoring the broker means monitoring
everything, not after initial connection.According to your snippet, the only
way to monitor the broker in a Spring Boot Actuator endpoint is to start the
connection in a separate Thread and check if it has been connected. There is
no other way to achieve this?Cheers,Filip

Sent from: