Shankar
Shankar

Reputation: 175

JMS Set Reply To Queue Manager

I want to set the required queue manager when sending a JMS message. Currently I am able to set the destination queue in the JMSReplyTO method, but I don't know how to also specify the queue manager.

TextMessage message = queueSession.createTextMessage();
message.setText(messageStr);
message.setJMSReplyTo(destinationQueue);
queueSender.send(message);

Upvotes: 3

Views: 9342

Answers (2)

Roger
Roger

Reputation: 7506

Here you go (for WebSphere MQ):

   MQQueue replyToQ = new MQQueue(QMgrName, ReplyQueue);
   Destination replyTo = (Destination) replyToQ;
   message.setJMSReplyTo(replyTo);

Upvotes: 4

Paul Hicks
Paul Hicks

Reputation: 14019

I don't know which MQ you're using, but your class names look like WebSphere's ones, so I'll guess that's it.

The queue manager name can be set on the connection factory, before you get a connection from it. Use MQConnectionFactory#setBrokerQueueManager(String).

The IBM javadocs for the method are here, on publib.

If you're using ActiveMQ, then you can't set the queue manager, since ActiveMQ doesn't support that abstraction. You could name your broker to be whatever you want your messages to use as their queue manager, since ActiveMQ brokers and MQ managers are roughly equivalent. I have no idea if that will help at all, though. You may have to switch to using WebSphere's own MQ.

Upvotes: 0

Related Questions