Reputation: 229224
I have a "server" application receiving messages from a JMS queue. And client applications which create a temp queue, and then send a message to the server, setting the JMSReplyTo header to the temp queue.
The server replies back to the client using the temp queue. However the server has a lot of replies back to the client all sent over the temp queue for a long period of time.(The replies are specific to that client, and are not interesting to anyone else)
How can my server detect if the client disconnected - so I can stop sending messages over that particular temp queue ? Or am I trying to do things with JMS I shouldn't ?
Upvotes: 0
Views: 1821
Reputation: 8534
With activeMQ, you can cast your temporary queue to a Destination and then interrogate the destination, e.g.
if (dest.getConsumers().size() < 1) {
// No more consumers on this destination, so kill it.
}
Or from the destination, get the DestinationStatistics
, and then get the queue depth from getMessages()
, if greater than n
then kill the tempQ.
Upvotes: 1
Reputation: 24272
Well, posting to that queue should fail since it should no longer exist once the client is gone. The temporary queue is only supposed to exist while the session that created it exists.
So I don't see that there is a need to be notified when the client is gone, which you can't do via JMS, as the attempt to send a reply message will in fact indicate this.
Upvotes: 0