You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Elliot Barlas <el...@gmail.com> on 2009/03/27 22:10:14 UTC

Re: Expired messages are not being removed from queues

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: 
http://www.nabble.com/How-to-purge-old-messages-when-no-consumer-exists--tt22745203.html

Have you implemented a workaround of some kind?

-Elliot
-- 
View this message in context: http://www.nabble.com/Expired-messages-are-not-being-removed-from-queues-tp21967682p22747936.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Expired messages are not being removed from queues

Posted by mcarter <mc...@funnelback.com>.
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.

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

Cheers,
Michael				


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: 
> http://www.nabble.com/How-to-purge-old-messages-when-no-consumer-exists--tt22745203.html
> 
> Have you implemented a workaround of some kind?
> 
> -Elliot
> 

-- 
View this message in context: http://www.nabble.com/Expired-messages-are-not-being-removed-from-queues-tp21967682p22773666.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.