'Any example of pausing and resuming JMS messages using JMSQueueControl

I read in the ActiveMQ Artemis documentation that we can pause and resume JMS message using JMSQueueControl, but I'm not able to find the interface in the latest jars.

Any code example would be appreciated.



Solution 1:[1]

According to the latest documentation, you can use QueueControl and there is such a class in the API.

Pausing and resuming Queues

The QueueControl can pause and resume the underlying queue. When a queue is paused, it will receive messages but will not deliver them. When it's resumed, it'll begin delivering the queued messages, if any.

Example of Usage:

String eapObjectName = "org.apache.activemq.artemis:broker=\"default\",component=addresses,address=\"jms.queue.exampleQueue\",subcomponent=queues,routing-type=\"anycast\",queue=\"jms.queue.exampleQueue\"";
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName objectName = ObjectName.getInstance(eapObjectName);
QueueControl queueControl = MBeanServerInvocationHandler.newProxyInstance(mBeanServer,objectName,QueueControl.class,false)

queueControl.pause();

References:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Justin Bertram