Can you just set the JMSExpiration message attribute ( http://activemq.apache.org/activemq-message-properties.html) so you know you don't have any pending messages older than a certain interval? Then the broker will automatically age off old messages, without you having to write any code. On Sep 15, 2015 3:21 PM, "mfan" <chaome...@gmail.com> wrote:
> I am using the QUEUE and the delivery mode is PERSISTENT. Somehow there are > probably some messages in the queue, so that I kept receiving the messages > were not produced currently. I found this link and plug the code provided > by > Tim, however I got the error. Would you please advise ? > > > http://stackoverflow.com/questions/16332205/clear-existing-messages-in-activemq-queue-just-after-starting-application-using > > error: cannot dynamic_cast '((Consumer*)this)->Consumer::connection' (of > type 'class cms::Connection*') to type 'class > activemq::core::ActiveMQConnection*' (target is not pointer or reference to > complete type) > > > > > > -- > View this message in context: > http://activemq.2283324.n4.nabble.com/The-old-messages-produced-before-are-received-currently-need-to-purge-the-messages-tp4702021.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. >