繁体   English   中英

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

[英]Same message posted to multiple queues from JMS code ActiveMQ

嗨,我正尝试根据某些数据条件将同一条消息发布到多个队列。

@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");
      } 

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

我也正在对此进行测试,但想知道是否有明显的遗漏之处。

TIA!

是的,它很好用。 两条消息将获得不同的消息ID,但否则应非常相似。

暂无
暂无

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

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