How can I programmatically clear my ActiveMQ queue using the Apache.NMS API?

I need the ability to programmatically clear a queue using Apache.NMS (C #). I am looking at the NMS API, but I don’t see this possibility. He exists?

+3
source share
2 answers

There is no direct way to drop the queue from the NMS API, which is more about the management function. You can specify an instance of IConnection in Apahce.NMS.ActiveMQ.Connection, and then call DeleteDestination. This will work if there are no consumers in the queue, but will throw an exception, if any.

+5
source

, "" ( ?), , :

ISession consumerSession = = connection.CreateSession(AcknowledgementMode.Transactional);

:

//will remove message from queue on success
consumerSession.Commit();

//on failure, back on queue
consumerSession.Rollback();
0

Source: https://habr.com/ru/post/1792313/


All Articles