ActiveMQ JobScheduler 移除消息 [英] ActiveMQ JobScheduler remove message

查看:105
本文介绍了ActiveMQ JobScheduler 移除消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过 Stomp 从 PHP 订阅 ActiveMQ 代理并访问 JobScheduler(然后通过其 jobId 删除预定消息)?

Is it possible to subscribe from PHP via Stomp to an ActiveMQ broker and access the JobScheduler (and subsequently remove a scheduled message by its jobId)?

我有一组由 2 个 Web 服务器生成的队列PROD"的预定消息,并且在同一 Web 服务器上发生事件(知道 jobId)时,想将它们从 JobScheduler 中删除,以便消费者(用 Java 编写并位于多个远程服务器上)不会收到它们.

I have a set of scheduled messages for a queue "PROD" produced from 2 web servers, and upon the occurrence of an event on the same web server (aware of jobIds), would like to remove them from the JobScheduler so that the consumers (written in Java and located on multiple remote servers) don't receive them.

我使用 ActiveMQ 代理 v5.9.1 和 Stomp 以 PHP 形式连接到代理.

I'm using ActiveMQ broker v5.9.1, and Stomp to connect to the broker form PHP.

推荐答案

您可以通过 STOMP 在 ActiveMQ 中管理计划作业.我已经之前写过这个展示了如何使用 ActiveMQ Java 客户端来完成,但原理是相同的.您可以发送带有特定标头集的消息,这些标头集将对计划的消息进行操作.

You can manage scheduled jobs in ActiveMQ over STOMP. I've written about this before showing how to do it using the ActiveMQ Java client but the principle is the same. You can send messages with specific headers set that will operate on the scheduled messages.

要删除使用 Java 客户端安排的消息,您需要执行以下操作:

To remove a message that was scheduled using the Java client you'd do the following:

    Message remove = session.createMessage();
    remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULER_ACTION,
            ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVE);
    remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_ID,
            scheduled.getStringProperty(ScheduledMessage.AMQ_SCHEDULED_ID));
    producer.send(remove);

记录了使用调度程序时可以使用的全套消息属性值 这里,在 STOMP 中只使用每个字符串的字面量作为消息属性.

The full set of message property values that can be used when working with the scheduler are documented here, in STOMP just use the string literal of each as the message property.

这篇关于ActiveMQ JobScheduler 移除消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆