[英]Same message posted to multiple queues from JMS code ActiveMQ
Hi I am trying to post the same message to multiple queues based on some data condition. 嗨,我正尝试根据某些数据条件将同一条消息发布到多个队列。
@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");
}
But i dont know when i send the message to the first queue will there be a message left to be sent to the second queue? 但是我不知道何时将消息发送到第一个队列,是否还有消息要发送到第二个队列? the message is captured in a onMessage method which is part of javax.jms.MessageListener class.
消息是在javax.jms.MessageListener类的onMessage方法中捕获的。
I am testing this out too but wondering if there is something obvious that i missed. 我也正在对此进行测试,但想知道是否有明显的遗漏之处。
TIA! TIA!
Yep, it works just fine. 是的,它很好用。 The two messages will get different message ids but should otherwise be very similar.
两条消息将获得不同的消息ID,但否则应非常相似。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.