Search code examples
androidjmsactivemq-classicstomp

Android Stomp reconnect to ActiveMQ



I am using some Stomp library for android. I already success to create connection and consume message from ActiveMQ. But now I have a problem.
Every time the client(android) lost connection(like no internet), it seems that the connection to activeMQ not properly shutdown, so when I try to reconnect, it always make a new consumer for the destination queue. What I want is the android will reconnect using the same session as before so it will not create a new consumer for the queue. Can someone help me to do something like this?


Solution

  • ActiveMQ identifies its durable STOMP subscriber with a client-id and subscriptionName. Client-id should be specified in the CONNECT message and subscriptionName should be specified in the SUBSCRIBE message. So, if you make sure that your subscriber uses the same client-id, subscriptionName combination every time it reconnects the ActiveMQ server, it should be treated as single client.

    Please see ActiveMQ STOMP Docs for more information, specifically ActiveMQ extensions to Stomp section.