简体   繁体   English

使用 JMSQueueControl 暂停和恢复 JMS 消息的任何示例

[英]Any example of pausing and resuming JMS messages using JMSQueueControl

I read in the activeMQ documentation that we can pause and resume JMS message using JMSQueueControl but not able to find the interface in the latest jars.我在 activeMQ 文档中读到,我们可以使用 JMSQueueControl 暂停和恢复 JMS 消息,但无法在最新的 jars 中找到接口。

https://activemq.apache.org/components/artemis/documentation/1.1.0/management.html https://activemq.apache.org/components/artemis/documentation/1.1.0/management.html

Any code example would be appreciated.任何代码示例将不胜感激。

According to the documentation, you can use QueueControl and there is such a class in the API.根据文档,您可以使用QueueControl ,并且在API中有这样一个class。

Pausing and resuming Queues暂停和恢复队列

The QueueControl can pause and resume the underlying queue. QueueControl 可以暂停和恢复底层队列。 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();

Documentation:文档:

https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/QueueControl.html https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/QueueControl.ZFC35FDC70D592C69D2E366

Github Reference: https://github.com/bershath/eap-clients/blob/aee5f911491d3a57270ef448793fd1178eed8f7c/eap-timers-jmx/src/main/java/org/jboss/labs/eap/timers/jmx/TimedNotifierTMR.java Github Reference: https://github.com/bershath/eap-clients/blob/aee5f911491d3a57270ef448793fd1178eed8f7c/eap-timers-jmx/src/main/java/org/jboss/labs/eap/timers/jmx/TimedNotifierTMR.java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM