activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zemus <>
Subject Problems with prefetch and TemporaryQueues
Date Tue, 12 Jan 2010 16:46:45 GMT


I have a problem where TemporaryQueues are left (with 0 consumers) after the
applications creating them have finished.

This scenario occurs for both ActiveMQ 4.1.1 and 5.3.0 on my P4 2.6 GHz, 3
GB RAM, Ubuntu 9.10, Sun JDK, default settings for ActiveMQ.

I've tried to recreate a simpler version of the scenario. Basically I have a
server that creates a Topic where clients that wants to subscribe may post a
message (with a TemporaryQueue as the JMS reply) in order to be added. The
server then has a thread that sends messages to all the TemporaryQueues. (I
know a simple Topic could push the updates here, but in the real system the
clients can receive information only intended for one single client.)

In my scenario the server is faster at generating messages than the clients
are in processing them so the queues start to build up. Pretty soon (if
clients are added and removed once a minute or so) it will hit a limit and
the processing of messages in the broker seems to come to a halt. I think it
is when the prefetch limit is reached.
The real problem here is that if a client disconnects successfully (might
hang in the broker communication) it is possible for the server to
"resurrect" its TemporaryQueue, probably by sending prefetchbuffered
messages to it. This way the TemporaryQueue is left on the broker with no
consumer (the client disconnected) with its queued up messages counting
towards the prefetch limit.

By running JConsole and purging the queue I can get the broker to wake up,
but if many messages are queued up the consumerless TempQueue will queue
those messages which might again cause the prefetch limit to be reached and
halt the broker.
Also, I've seen old TemporaryQueues that were removed minutes ago come back
and start queueing buffered messages when I start purging other consumerless

In short I think there are two problems here.
First, the detection of the client disconnection is not instant on the
server. This makes it possible to send messages to the TemporaryQueue
without getting an exception after it should have been removed.

The second is that the TemporaryQueue is able to resurrect after its
creator/consumer has left. In other words it has outlived its connection.

I attach a simple client and server that are able to reproduce this reliably
(at least on my computer).
Just run the server and maybe two clients. Restart the clients perhaps 1-2
times per minute and the issue will show pretty quickly. At least on my P4,
maybe a computer with multiple cores will behave different.

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message