ActiveMQ - preserve consumers during a failover

86 Views Asked by At

Broker URL

failover:(tcp://broker1:61616,tcp://broker2:61616)?randomize=false&jms.useAsyncSend=false&jms.dispatchAsync=false&maxReconnectAttempts=2&maxReconnectDelay=100

I register a message listener on the active broker:

  Destination destQueue = new ActiveMQQueue("queue");
  MessageConsumer messageConsumer = session.createConsumer(destQueue);
  messageConsumer.setMessageListener(consumer);

During a failover the consumer disapears and is not re-registered on the second broker. Can you give me some light how could I register the listener on the other broker automatically upon failover?

thanks in advance

1

There are 1 best solutions below

0
On

Found out - the problem was because I used PooledConnectionFactory for listener's code. Replaced with ActiveMQConnectionsFactory and it worked.