gpt4 book ai didi

java - Websphere MQ JMSTemplate 设置 ReplyTo

转载 作者:行者123 更新时间:2023-11-30 08:50:04 28 4
gpt4 key购买 nike

我正在尝试将带有 replyTo 属性的消息发送到 WebSphere MQ。

@SpringBootApplication
public class WmqSenderApplication {

public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(WmqSenderApplication.class, args);
JmsTemplate jmsTemplate = ctx.getBean(JmsTemplate.class);
jmsTemplate.send("TEST_QUEUE",new MessageCreator() {

@Override
public Message createMessage(Session session) throws JMSException {
TextMessage message = session.createTextMessage();
message.setJMSReplyTo(new MQDestination("REPLY_QUEUE"));//com.ibm.mq.jms.MQDestination
return message;
}
});

}

@Bean
public MQQueueConnectionFactory connFac() throws JMSException {
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
cf.setTransportType(1);
cf.setHostName("localhost");
cf.setPort(1417);
cf.setQueueManager("TEST");
cf.setChannel("CHANNEL");
return cf;
}
@Bean
public JmsTemplate jmsTemplate() throws JMSException {
return new JmsTemplate(connFac());
}
}

但是我得到了:

com.ibm.msg.client.jms.DetailedInvalidDestinationException: 
JMSCMQ0005: The destination name '://REPLY_QUEUE' was not valid. The destination name specified does not conform to published destination syntax. Correct the specified destination name and try again.

我在代理中创建了 REPLY_QUEUETEST_QUEUE

最佳答案

setJMSReplyTo 方法采用 javax.jms.Destination 类型的对象。您将需要创建一个 javax.jms.Destination 类的实例。您可以创建临时队列或永久队列。

     Destination replyToQ = session.createQueue("REPLYQ");
TextMessage message = session.createTextMessage();
message.setJMSReplyTo(replyToQ);
return message;

关于java - Websphere MQ JMSTemplate 设置 ReplyTo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31163145/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com