gpt4 book ai didi

java - 从 JMS 代码 ActiveMQ 将同一消息发布到多个队列

转载 作者:行者123 更新时间:2023-11-30 03:24:29 25 4
gpt4 key购买 nike

您好,我正在尝试根据某些数据条件将相同的消息发布到多个队列。

@Override
public void onMessage(Message msg) {
// TODO Auto-generated method stub

if (msginstanceof TextMessage) {

if(<data check1>){
Destination destination = session.createQueue("inbound.1");
MessageProducer producer = session.createProducer(destination);
log.info("Preparing to send to queue1");
producer.send(msg);
log.info("Message sent to queue1");

}
if(<data check 2>){
Destination destination = session.createQueue("Queue2");
MessageProducer producer = session.createProducer(destination);
log.info("Preparing to send to Queue2");
producer.send(msg);
log.info("Message sent to Queue2");
}

但是我不知道当我将消息发送到第一个队列时是否还会有消息发送到第二个队列?消息在 onMessage 方法中捕获,该方法是 javax.jms.MessageListener 类的一部分。

我也在测试这个,但想知道是否有一些明显的东西我错过了。

TIA!

最佳答案

是的,它工作得很好。这两条消息将获得不同的消息 ID,但在其他方面应该非常相似。

关于java - 从 JMS 代码 ActiveMQ 将同一消息发布到多个队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30604051/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com