« Return to Thread: Getting Durable Messages After Failover

Re: Getting Durable Messages After Failover

by aortiz :: Rate this Message:

Reply to Author | View in Thread

You need to replicate the messages between the two brokers.
See http://activemq.apache.org/clustering.html and look for "Master Slave" or "Replicated Message Stores"

--
Open Source Integration
http://fusesource.com

DCMH wrote:
This is the first time I'm using ActiveMQ, the version I'm using is 5.2, below is my configuration:

I have 2 ActiveMQ brokers setup in a cluster.

Both brokers have the following conf:
<networkConnectors>
  <networkConnector name="MQ" uri="static://(tcp://{IP of broker 1}:61616,tcp://{IP of broker 2}:61616)"/>
</networkConnectors>
....
<transportConnectors>
  <transportConnector name="openwire" uri="tcp://localhost:61616"/>
  <transportConnector name="ssl" uri="ssl://localhost:61617"/>
  <transportConnector name="stomp" uri="stomp://localhost:61613"/>
  <transportConnector name="xmpp" uri="xmpp://localhost:61222"/>
</transportConnectors>


I have a client use the failover protocol to connect to the broker cluster :
failover://(tcp://{IP of broker 1}:61616,tcp://{IP of broker 2}:61616)

The client intends to consume the durable messages from a topic: DurableTopic.

There is a message producer constantly producing durable messages to a topic: DurableTopic.

When the client starts, it connects to broker 1 and subscribes to the DurableTopic at broker 1 and consumes the messages produced by the message producer. At some time, the client quits abnormally (without unsubscribing to the DurableTopic at broker 1) while the message producer keeps publishing messages.

I suppose that after the client reconnects to the broker cluster (using the same failover protocol) will be able to consume the durable messages generated by the producer since its abnormal exit.

However, I found that there are 2 possible cases:
(i) the client reconnects to broker 1
(ii) the client reconnects to broker 2

In case (i), the outcome is what I expected, the client is able to consume the messages. However, In case (ii), the client is not able to consume those messages after reconnecting to another broker.

It seems to me that when the client connects to another broker, it is not able to resume the previous session even I use the same name to create the durable subscriber.

I have to try to reconnect the client until it reconnects to broker 1 in order to consume the durable messages.


Is there anyway that I can make my client able to consume the durable messages after reconnection (no matter to broker 1 or broker 2)?
Or I have missed anything in the broker configuration?


Much appreciated if anyone can give me some ideas.
Thanks


 « Return to Thread: Getting Durable Messages After Failover