简体   繁体   English

如何删除activemq中的特定队列

[英]how to delete a specific queue in activemq

i want to delete a specific queue from consumer after getting the message from queue in activemq. 我想从activemq的队列中获取消息后,从使用者中删除特定的队列。 i read many articles but none of them giving good explanation.i can provide either queue name or correlationID for deleting the queue. 我读了很多文章,但都没有给出很好的解释。我可以提供队列名称或correlationID以删除队列。 please give some suggestion. 请提出一些建议。

version :-Activemq 5.8.0 . 版本:-Activemq 5.8.0。 advance thanks 提前谢谢

I got the answer.delete a queue programmatically from a java program 我得到了答案。以编程方式从Java程序删除队列

 JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
MBeanServerConnection conn = jmxc.getMBeanServerConnection();

String operationName="removeQueue"; //operation like addQueue or removeQueue
String parameter="Payment_Check";   // Queue name
ObjectName activeMQ = new ObjectName("org.apache.activemq:brokerName=localhost,type=Broker");
if(parameter != null) {
    Object[] params = {parameter};
    String[] sig = {"java.lang.String"};
    conn.invoke(activeMQ, operationName, params, sig);
} else {
    conn.invoke(activeMQ, operationName,null,null);
} 

you want to change in activemq config file.in default createConnector="false".change to createConnector="true".otherwise you will get error like 您要在activemq配置文件中更改。默认情况下,createConnector =“ false”。更改为createConnector =“ true”。否则您将收到类似

 Exception in thread "main" java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException.

this concept is explained in "ben.odey"'s article "managing ActiveMQ with JMX APIs". “ ben.odey”的文章“使用JMX API管理ActiveMQ”中对此概念进行了解释。 Link:- managing ActiveMQ with JMX APIs 链接:- 使用JMX API管理ActiveMQ

I also get like your problem. 我也喜欢你的问题。 I fixed like that here . 在这里这样固定。 It is using QueueViewMBean . 它使用QueueViewMBean Which have removeMessage function. 里面有removeMessage功能。 You just need to pass messageid . 您只需要传递messageid

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

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