activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlittman <>
Subject Re: Detecting lost clients
Date Sun, 03 Sep 2006 15:32:14 GMT

It looks like I'm close, maybe someone can suggest the last piece.

Following basic instructions found in:

Subscribe to ActiveMQ.Advisory.Connection. Can keep track of connections
coming and going as follows:
    public void onMessage(Message msg) {
        ActiveMQMessage activeMQMessage = (ActiveMQMessage) msg;
        if (activeMQMessage.getDataStructure() instanceof ConnectionInfo) {
            ConnectionInfo connectionInfo = (ConnectionInfo)
  "received connection notice " +
        } else if (activeMQMessage.getDataStructure() instanceof RemoveInfo)
            RemoveInfo removeInfo = (RemoveInfo)
  "received remove notice " +

and when I receive a message, I try to correlate it with my connected client
as follows:

        ActiveMQMessage activeMQMessage = (ActiveMQMessage) jmsMessage;
        ProducerId producerId = activeMQMessage.getProducerId(); ("producer id is " + producerId); ("connection id is " +

The problem is that the output is:

2006-09-03 08:15:56,439 INFO  [Thread-35] - received connection
notice ID:server-corp-2975-1157296540985-18:0
2006-09-03 08:16:03,611 INFO [Thread-38] controller.onMessage - producer id
is ID:server-corp-2975-1157296540985-18:0:-1:1
2006-09-03 08:16:03,611 INFO [Thread-38] controller.onMessage - connection
id is ID:server-corp-2975-1157296540985-6:4

So the connectId doesn't match, but the producerId *almost* matches. So I
guess I don't quite have the way to match the connection events with the
incoming messages.

jlittman wrote:
> From my ActiveMQ server application, I want to be able to detect when a
> client has disappeared (i.e. crash) without explicitly closing the
> application level session. What I'd like to do is the following:
> 1) receive ApplicationConnect message from a client. Save some sort of an
> id representing the connection.
> 2) If the application disconnects or exits ungracefully without sending an
> ApplicationDisconnect message, I want to receive notification that the
> client with the given id is gone, and I should clean up all relevant
> state, locks, etc....
> I can set up a MessageListener interested in topic
> ActiveMQ.Advisory.Connection, and I get a message delivered when clients
> connect and when they disconnect or crash. When I get a JMS message for
> ApplicationConnect, I can see that there is ConnectionInfo in the data
> structure for Message. However, I don't see any values that correlate with
> the ConnectionInfo received in the ActiveMQ.Advisory.Connection topic
> message. There's a clientId, sessionId etc... but they don't seem to be
> the value I am after. Is there a value here that I can use, or is there a
> better way to build this mousetrap altogether? Thanks in advance for any
> tips.

View this message in context:
Sent from the ActiveMQ - User forum at

View raw message