activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcarter <>
Subject Re: Expired messages are not being removed from queues
Date Sun, 29 Mar 2009 22:32:47 GMT

Hi Elliot,

Yes I was quite disappointed to figure out that ActiveMQ was just leaving
those messages around. Particularly since it caused queues to seize up and
become useless, even after following all the advice out there about turning
off producer flow control.

In the end I implemented a workaround that was simply a thread that
periodically cleared my queues of expired messages. The way it did so was to
use a MessageConsumer and use a JMSSelector to consume only those messages
that had expired. I don't believe the consumer itself actually ever receives
any messages, but the act of looking for them causes ActiveMQ to expunge the
expired messages.

                MessageConsumer c = sess.createConsumer(dest, "JMSExpiration
< " + System.currentTimeMillis());
                Message m = c.receiveNoWait();
                if (m != null) log.error("Returned an expired message");


Elliot Barlas wrote:
> Hey Michael, it turns out that the activemq broker actually does not
> proactively purge expired messages from queues.  The broker will not send
> expired messages to consumers, but if there are no consumers consuming
> from the queue, expired messages just sit.  
> Today I made a similar post: 
> Have you implemented a workaround of some kind?
> -Elliot

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

View raw message