0
votes

How can I clear / purge a selected queue (ex. FOO.BAR) when I start or restart the activeMQ instance.

Is there a way I can configure in activemq.xml or any other way to handle this?

Please note that Im having cluster envitonment which is currently running two instance of ActiveMQs (instance1 and instance2).

Note : I donot want to use deleteAllMessagesOnStartup="true" as it will delete all the Available Queues.

Im trying to use Apache Camel with ActiveMQ. So please let me know if we can get this done with Camel as well.

3

3 Answers

2
votes

You would need to use the JMX purge method to clear the Queue, or use the deleteAllMessagesOnStartup. There is no configuration for purging a single Queue or set of Queues, this is a management operation. If you need messages to go away after some time then consider using a time to live on the Messages.

0
votes

What you could do is customize your activemq startup script to

  1. start activemq (obviously)
  2. use activemq-admin.bat or activemq-admin.sh to purge selected queues

syntax looks like this:

activemq-admin.bat purge name_of_your_broker name_of_the_queue

The trick here would be to launch only the second script when activemq is completely initialized.

0
votes

Since I couldn't find any strait forward answer, I thought to handle with ApacheCamel. Set the

ProducerTemplate sendBody 

as

ascExchangePattern.InOut

So if the client is disconnected or if the ActiveMQ isntance is restarted then those pending queue messages would goed to the Dead Letter Queue which I can process those messages later.