MQJE001: Completion Code '2', Reason '2033' issue in IBM Only For Getting Some Messages

Carlos Reyes :

I am currently reading from a remote queue, which is filled with transactions (messages). I am reading it by accessing the queue and measuring the size of records.

getOptions.options = MQC.MQGMO_CONVERT + MQC.MQGMO_WAIT;
queue.getCurrentDepth();

Only when the size of the queue is greater than 0. I proceed to get the message.

My problem is that for some messages I get the following error: MQJE001: Completion Code '2', Reason '2033'.

But only for some messages, the funny thing is that I have a custom retry variable and the 3rd retry gets a blank message.

My possible solutions:

At first I thought it could be the waitInterval and I have been varying it from 150 ms to 30 seconds. For some messages I get them correctly in less than 100 ms. But the messages that give me problems take all the waitInterval and then give the error and get the blank message to the third retry.

The second test was to verify the parameters of the MQMessage class, where I originally have:

  • messageType: 8
  • encoding: 273
  • format:
  • characterSet: 0

When I get a message correctly, the following parameters remain:

  • messageType: 8
  • encoding: 273
  • format: MQSTR
  • characterSet: 819

When I have a message that causes error 2033 at the third retry I get a blank message and the parameters change to the following:

  • messageType: 8
  • encoding: 273
  • format:
  • characterSet: 819

I came to think that the messages in the queue were not indicating the correct format. So I contacted support and they verified that all messages have the correct conversion headers.

So I am still in doubt as to why this problem, if someone has faced something similar, would appreciate your comment. Thank you.

Roger :

You are treating IBM MQ as a database and that will cause you all kinds of grief.

This is how you should be retrieving the messages:

MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = CMQC.MQGMO_WAIT + CMQC.MQGMO_FAIL_IF_QUIESCING;
gmo.waitInterval = 5000;  // wait up to 5 seconds
MQMessage receiveMsg = null;
boolean getMore = true;

while(getMore)
{
   receiveMsg = new MQMessage();

   try
   {
      // get the message on the queue
      queue.get(receiveMsg, gmo);

      /*
       * Now go do something with the message
       */
   }
   catch (MQException e)
   {
      if ( (e.completionCode == CMQC.MQCC_FAILED) &&
           (e.reasonCode == CMQC.MQRC_NO_MSG_AVAILABLE) )
      {
         // No message - loop again
      }
      else
      {
         System.out.println("MQException: " + e.getLocalizedMessage());
         System.out.println("CC=" + e.completionCode + " : RC=" + e.reasonCode);
         getMore = false;
      }
   }
   catch (IOException e)
   {
      System.out.println("IOException:" +e.getLocalizedMessage());
   }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=311550&siteId=1