Have a message in Websphere MQ. Have read the message and I am trying to backout the message to Input Queue. Retry threshold not yet reached. Does the MQ message automatically put into Input Q when exception occurs? This is my code:
MQQueueManager qm = new MQQueueManager("");
MQQueue q = qm.accessQueue("");
MQMessage message = new MQMessage();
q.get(message);
System.out.println("Retry Count"+ message.backoutCount);
throw new NullPointerException;
Will the above code put the message to Input Queue again? In this case, it is not putting message back to Input Queue. Message is lost.
Your message can only be backed out if it was part of a transaction to begin with. Your code doesn't use transactions.
Take a look at the MQGMO options, MQGMO_SYNCPOINT
and MQGMO_SYNCPOINT_IF_PERSISTENT
(search for the string MQGMO_SYNCPOINT
in the below two links).
MQ Java Classes CMQC constants
MQ API description of MQGMO_SYNCPOINT - applicable to all languages
And also the commit() and backout() methods on the MQQueueManager
:
and suggest you read this general purpose explanation of transactions