Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel ActiveMQ message

I'm not sure if ActiveMQ is a right tool here...

I have a task queue and multiple consumers, so my idea was to use ActiveMQ to post tasks, which are then consumed by consumers.

But I need to be able to cancel the task, if it was not processed yet...

Is there an API for removing Message from Queue in ActiveMQ?

Destination destination = session.createQueue(TOPIC_NAME);
MessageProducer producer = session.createProducer(destination);
ObjectMessage message = session.createObjectMessage(jobData);
producer.send(message);
...
producer.cancel(message); (?)

The use-case is that, for any reason, performing the task is no longer needed, and the task is resource-consuming.


1 Answers

What about setting an expiry time on the message? http://activemq.apache.org/how-do-i-set-the-message-expiration.html

If you want a message to be deleted if it has not been processed / consumed in a particular time frame, then message expiry seems the answer to me.

like image 142
Torsten Mielke Avatar answered Feb 01 '26 20:02

Torsten Mielke