Unable to remove ActiveMQ ScheduledMessage?
Unable to remove ActiveMQ ScheduledMessage?
I am trying to remove scheduled delayed message through Thoughts of Tim Bish
Message scheduled properly but unable to remove scheduled message.
Am using ActiveMq-5.15.3
Also enabled schedulerSupport="true" from activemq.xml
Here is my code
/**
* #1 Send 5 message with delayed time 60sec's
*/
//send delayed message
Destination destination = session.createQueue("test");
producer = session.createProducer(destination);
Message message = session.createTextMessage(getCustomerMessage());
long delay = 1 * 1000*60;
message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);
for(int i=0; i<5; i++{
producer.send(message);
}
//end
After ran above code then web console show result like below screen shot.
Scheduled tab:
After one minute all messages moved to queues (like normal messages) that's fine.
But, I want to cancel all scheduled message and No need to put queues.
I run below program for remove all scheduled messages. (before 1 minute)
//remove all schedule
Destination destination = session.createQueue("test");
MessageProducer mproducer = session.createProducer(destination);
Message request = session.createMessage();
request.setStringProperty(ScheduledMessage.AMQ_SCHEDULER_ACTION,
ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVEALL);
mproducer.send(request);
//end
Above code Not removed from scheduled message. Just put into queues as normal message.
Tried also
createTopic(ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION)
instead of createQueue("test")
remove through browse property also not work
browser.receive(5000);
browser.receive always return null
Please correct me what am I doing wrong ?
Thanks
@TimBish Updated my question. Please look at again
– Siva Psr
2 days ago
1 Answer
1
You are trying to remove all scheduled messages from a real destination and not the management destination for the Scheduler. You should be directing the remove-all to the management destination as below:
Destination management = session.createTopic(ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION);
MessageProducer mproducer = session.createProducer(destination);
Message request = session.createMessage();
request.setStringProperty(ScheduledMessage.AMQ_SCHEDULER_ACTION,
ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVEALL);
mproducer.send(request);
Thanks lot , both (remove all and specific message) are working fine. Now I am understand properly. Thanks again.
– Siva Psr
2 days ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Do you have the scheduler enabled? How do you know the job is not removed? More information is required
– Tim Bish
2 days ago