springboot集成activeMQ实现多个队列和主题同时收和发(4)

多个queue接收代码

1  queue1接收代码
@Component
public class QueueReceiver1 {

///
/// 日志记录
///

private static Logger logger = LoggerFactory.getLogger(QueueReceiver1.class.getName());

@JmsListener(destination = "${application.queueDestinationName1}",containerFactory="queueListenerFactory")
public void receiveQueue(String text) {
logger.info("===========队列消费者1Queue接受的消息为==============:" + text);
}

//如果多个消费者同时消费1个队列,QueueReceiver写多个
}
2  queue2接收代码
@Component
public class QueueReceiver2 {

///
/// 日志记录
///

private static Logger logger = LoggerFactory.getLogger(QueueReceiver2.class.getName());

@JmsListener(destination = "${application.queueDestinationName2}",containerFactory="queueListenerFactory")
public void receiveQueue(String text) {
logger.info("===========队列消费者2Queue接受的消息为==============:" + text);
}

}

你可能感兴趣的:(springboot)