• 1 reply
  • Latest Post - ‏2013-04-21T23:44:01Z by GBaddeley
5 Posts

Pinned topic How to stop messages getting overwritten?

‏2013-04-19T19:56:40Z | c# ibm mq


I am sending 3 messages
Message1 - correlation id:5000
empty message (no body/message)-correlation id:5001
Message2 - correlation id:5002
My outbound queue processes like this
Message1 - correlation id:5000
*Message1-correlation id:5001 => same previous message ovewritten on the empty message.**
Message2 - correlation id:5002
The second line above should not have had Message1, instead just empty. Any thoughts?
> My get method
                    mqGetMsgOpts = new MQGetMessageOptions();
                    if (mqQueue != null)
                        //Get options for the messsage                
                        mqGetMsgOpts.Options = MQC.MQGMO_BROWSE_FIRST | MQC.MQGMO_WAIT |  MQC.MQOO_INQUIRE;
                        mqGetMsgOpts.MatchOptions = MQC.MQMO_NONE;
                        mqGetMsgOpts.WaitInterval = 5000;  // 5 seconds limit for waiting
                  if (mqMsg.MessageLength > 0 && mqMsg.DataLength > 0)
                    messageData = mqMsg.ReadString(mqMsg.MessageLength);
If  I don't do the length check, i will get stream reader related exception.
> My put method
      mqQueue = mqQMgr.AccessQueue("Queue Name", MQC.MQOO_OUTPUT | MQC.MQOO_INPUT_SHARED | MQC.MQOO_INQUIRE);


Updated on 2014-02-19T13:12:09Z at 2014-02-19T13:12:09Z by Morag Hughson
  • GBaddeley
    302 Posts

    Re: How to stop messages getting overwritten?


    It looks like when you put the 2nd message the message length and data where still set in the Java program from when you put the 1st message.

    MQ cannot possibly "overwrite" messages on a queue. All messages are atomic and can only be put or get as individual messages. There is no concept of overwrite or update in MQ.


    HTH, G.