It looks like I'm close, maybe someone can suggest the last piece. Following basic instructions found in: http://www.activemq.org/site/advisory-message.html
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) activeMQMessage.getDataStructure(); logger.info("received connection notice " + connectionInfo.getConnectionId()); } else if (activeMQMessage.getDataStructure() instanceof RemoveInfo) { RemoveInfo removeInfo = (RemoveInfo) activeMQMessage.getDataStructure(); logger.info("received remove notice " + (ConnectionId)removeInfo.getObjectId()); } } 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(); logger.info ("producer id is " + producerId); logger.info ("connection id is " + activeMQMessage.getConnection().getConnectionInfo().getConnectionId()); The problem is that the output is: 2006-09-03 08:15:56,439 INFO [Thread-35] com.dmarc.ras.common.server.ConnectionMonitor.info - 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: http://www.nabble.com/Detecting-lost-clients-tf2208237.html#a6123603 Sent from the ActiveMQ - User forum at Nabble.com.