Question

I have experienced the following situation with an ActiveMQ Pub/Sub implementation. If the connection to the message broker is lost the publisher could re-try to establish a connection since the publish method would throw an exception.

However if the connection to the message broker is lost at the subscriber end, the subscriber would not know it. This would be the same if the session expires.

Proposed solution: One of the solutions I thought was to implement a heartbeat at the subscriber end to periodically publish a ping message to a separate topic so that the subscriber could know if the connection is dropped. This works fine, but the down side is that the amount of ping messages generated by the subscribers available in the system. The second option I thought was to implement the heartbeat to try and create a connection in an interval. WDYT?

Do you see a better way of implementing this? Appreciate your thoughts.

Était-ce utile?

La solution

Use the ActiveMQ Failover transport and don't disable the inactivity monitor and the client will check the connection and automatically reconnect as needed. Without more information on you set-up that's about the best answer.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top