0
votes

Is there a IBM MQ JAVA API to move messages from one queue to another?

I am able to browse messages from the queue and put messages as well using Java APIs. But I want to move a message from one queue to another. Could you please give a sample code if there is any?

Or do we have to dequeue the message from queue1 and then put the message into queue2 for moving the messages?

2
If you can explain why you want to do that then we can answer it better...I say because you can make the source Q a transmission Q in MA - Aravind Yarram
Ok. My java app totally deals with queues. A message would travel from one queue to another and the whole flow in controlled that way. In case of any issues while processing messages from the queue, we need to put the message into an ERROR Queue. There is a UI by which we can review the message put in Error queue. Once a review of the message is done, a user can queue it to the original queue from which the message was dequeued. Hence I need to use JAVA MQ APIs for the desired functionality. I have no control of the queue configuration. I just have the list of queue names which we have to use - user1166031

2 Answers

1
votes

You need to GET from queue 1 and then do a PUT on queue 2. If you just browse then there are chances that before yoy GET it out of queue 1, the consumer have already consumed it using GET. You can find sample code for many scenarios on this website.

0
votes

I have faced the same issue and after lot of frustrating hours i have done it using tool "MQJExplorer_v0.16". Using this tool you can export/import all the messages(or a single message) from one queue to another queue.

If you are facing any issues while installation. Please make sure you are using the correct jdk version (I faced the same issue). You can check the java version in the MetaInf file of one of the downloaded artifacts, make sure you have the same jdk or newer version on your localmachine and just set the JAVA_HOME in the environment variables.