Issue while having an empty message in between actual messages
Test1 - Message1
Test3 - Message3
When above messages are processed, there is an exception thrown.
while(if any message is available)
//go a read/get
mqMsg = new MQMessage();
mqGetMsgOpts = new MQGetMessageOptions();
messageData = mqMsg.ReadString(mqMsg.MessageLength); => this line fails when an empty message is processed. (exception is shown below)
another method(send) - sends it.
mqPutMsgOpts = new MQPutMessageOptions();
How do i handle this? (so that MQ processes empty message(no data/body) without any exception and continues to the next message? Thanks in advance.
System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at IBM.WMQ.MQMessage.ReadString(Int32 length)
I tried to add this line
messageData = mqMsg.ReadString(mqMsg.MessageLength);
mqMsg.Seek(0); => but this didn't help.
aschneid 120000J10Q5 Posts
Re: Exception with blank message.2013-04-06T11:43:14ZThis is the accepted answer. This is the accepted answer.Why don't you just check mqMsg.MessageLength and only call the read method when there is data (length > 0 )
Or what is the problem then?