ActiveMQ - 以编程方式删除队列

发布于 2024-09-05 18:13:10 字数 210 浏览 2 评论 0原文

StackOverflowers 同胞,有没有办法以编程方式删除 ActiveMQ 中的队列或主题?我正在使用 ActiveMQ 的标准持久性,并且我的应用程序要求在启动时动态重新创建所有新队列(除非队列中存储有消息,在这种情况下,队列应保持存在)。

我还通过会话以编程方式创建所有队列。是否有与该过程等效的方法,仅删除队列?查询和迭代现有队列也很有用,但我还没有找到一种方法来做到这一点。

Fellow StackOverflowers, is there a way for me to remove a queue or a topic in ActiveMQ programmatically? I am using ActiveMQ's standard persistency, and my application requires that, on startup, all new queues be dynamically re-created (unless there are messages stored in the queue, in which case, the queue should remain to exist).

I am also creating all queues programmatically through sessions. Is there an equivalent to that procedure, only to delete a queue? Querying and iterating through the existing queues would also be useful, but i haven't found a way to do that yet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

桃扇骨 2024-09-12 18:13:11

虽然没有很多具体的例子,但这里有一些关于它的文档:
http://activemq.apache.org/how-do- i-purge-a-queue.html

While there's not a lot of concrete examples, there's some documentation about it here :
http://activemq.apache.org/how-do-i-purge-a-queue.html

罪#恶を代价 2024-09-12 18:13:10

您还可以删除在一段时间内不活动的目标。自 Active MQ 5.4 起可用

或者,如果您运行嵌入式 ActiveMQ,则可以使用 API 删除目标: Region.removeDestination< /a>

You can also Delete Destinations that are inactive for some period of time. Available since Active MQ 5.4

Alternatively if you are running ActiveMQ embedded you can use the API to remove destinations: Region.removeDestination

才能让你更想念 2024-09-12 18:13:10

要以编程方式从 ActiveMQ 中删除目标,您需要通过 JMX 使用代理 MBean (org.apache.activemq: BrokerName=localhost,Type=Broker)。我在 Gist 上发布了一些示例代码来演示这一点,包括使用 removeTopic 方法:

http://gist.github.com/439668

希望有帮助。

布鲁斯

To remove a destination from ActiveMQ programmatically, you will need to do so via JMX using the removeTopic and removeQueue methods on the broker MBean (org.apache.activemq:BrokerName=localhost,Type=Broker). I have posted some example code to demonstrate this, including the use of the removeTopic method, over on Gist:

http://gist.github.com/439668

Hope that helps.

Bruce

梦行七里 2024-09-12 18:13:10

如果你使用spring JmsTemplate,你可以这样做:

Connection cn = getJmsTemplate().getConnectionFactory().createConnection();
ActiveMQDestination destination = ActiveMQDestination.createDestination(queueName, ActiveMQDestination.QUEUE_TYPE);             

if(cn instanceof PooledConnection){
    ((PooledConnection)cn).getConnection().destroyDestination(destination );
}

If you use spring JmsTemplate, you can do it this way:

Connection cn = getJmsTemplate().getConnectionFactory().createConnection();
ActiveMQDestination destination = ActiveMQDestination.createDestination(queueName, ActiveMQDestination.QUEUE_TYPE);             

if(cn instanceof PooledConnection){
    ((PooledConnection)cn).getConnection().destroyDestination(destination );
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文