获取JMSMessageID Spring

时间:2018-01-19 08:38:14

标签: spring jms ibm-mq

我正在发送JMS消息:

jmsTemplate.send("COM.YA.ADAPTER.AFM.TEST.OUT", session -> {
            TextMessage message = session.createTextMessage(msg);
            return message;
        });

想在另一个帖子中得到答案:

TextMessage textMessage = (TextMessage) jmsTemplate.receiveSelected("COM.YA.ADAPTER.AFM.TEST.IN",
                    "JMSCorrelationID='" + msgID + "'");

发送功能不返回messageid。哪里可以找到它? UP: 刚刚找到了解决方案

 Session session = jmsTemplate.getConnectionFactory().createConnection().createSession();
    TextMessage message = session.createTextMessage(msg);
    jmsTemplate.send(AntiFraudRq, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            return message;
        }
    });
    LOGGER.error(message.getJMSMessageID());

但每次创建一个会话是否正常?

0 个答案:

没有答案