【问题标题】:how to delete a specific queue in activemq如何删除activemq中的特定队列
【发布时间】:2013-11-22 21:08:35
【问题描述】:

在从activemq 的队列中获取消息后,我想从消费者那里删除一个特定的队列。我阅读了很多文章,但没有一篇给出很好的解释。我可以提供队列名称或相关 ID 来删除队列。请给点建议。

版本:-Activemq 5.8.0。提前谢谢

【问题讨论】:

  • 您想如何从 java 代码或某些管理控制台中删除队列? JMS 上有 API 可以删除队列,ActiveMQ 也有 JMX API 可以删除队列
  • @ClausIbsen 感谢您的回复。我得到了答案。我想从java代码中删除。我确实使用了这个链接consulting-notes.com/2010/08/…

标签: java activemq messaging jmx


【解决方案1】:

我得到了答案。以编程方式从 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);
} 

你想改变 activemq 配置文件。在默认 createConnector="false".change 到 createConnector="true"。否则你会得到类似的错误

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

“ben.odey”的文章“使用 JMX API 管理 ActiveMQ”中解释了这个概念。 链接:-managing ActiveMQ with JMX APIs

【讨论】:

  • 需要将其用作 ObjectName:org.apache.activemq:BrokerName=localhost,Type=Broker
【解决方案2】:

我也喜欢你的问题。我就这样修复了here。它正在使用QueueViewMBean。其中有removeMessage 功能。你只需要传递messageid

【讨论】:

    猜你喜欢
    • 2014-09-17
    • 1970-01-01
    • 2021-03-08
    • 2014-09-14
    • 2012-08-17
    • 1970-01-01
    • 1970-01-01
    • 2018-09-28
    • 1970-01-01
    相关资源
    最近更新 更多