从 JMS 代码 ActiveMQ 发布到多个队列的相同消息

Same message posted to multiple queues from JMS code ActiveMQ

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

@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 class.

的一部分

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

TIA!

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