Reputation: 22496
I'm trying to send message with replyTo
property to 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());
}
}
But I got:
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.
I got both REPLY_QUEUE
and TEST_QUEUE
created in the broker.
Upvotes: 2
Views: 2839
Reputation: 15263
The setJMSReplyTo
method takes an object of type javax.jms.Destination
. You will need to create an instance of a javax.jms.Destination
class. You can create either a temporary queue or a permanent queue.
Destination replyToQ = session.createQueue("REPLYQ");
TextMessage message = session.createTextMessage();
message.setJMSReplyTo(replyToQ);
return message;
Upvotes: 4
Reputation: 22496
Managed to do it with:
jmsTemplate.send("TEST_QUEUE",new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
TextMessage message = session.createTextMessage();
Queue queue = session.createQueue("REPLY_QUEUE");
message.setJMSReplyTo(queue);
return message;
}
});
Upvotes: 1