|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Put/get messages to/from the same queue concurrent |
« View previous topic :: View next topic » |
Author |
Message
|
XianWeng |
Posted: Wed Feb 25, 2009 3:11 pm Post subject: Put/get messages to/from the same queue concurrent |
|
|
Newbie
Joined: 25 Feb 2009 Posts: 2
|
Hello,
I am new to MQ. I have developed two applications using MQ .NET API.
The App1 connects to a queue, in a loop put messages in the queue, at the end close the connection.
The open options: MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING
Code: |
MQMessage mqMessage = new MQMessage();
mqMessage.Format = MQC.MQFMT_STRING;
mqMessage.WriteString(strMessage);
MQPutMessageOptions mqPutMsgOpts = new MQPutMessageOptions();
mqQueue.Put(mqMessage, mqPutMsgOpts);
|
The App2 connects to the same queue, in a loop get messages from the queue, at the end close the connection.
The open options: MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING
Code: |
MQGetMessageOptions mqGetMsgOpts = new MQGetMessageOptions();
mqGetMsgOpts.WaitInterval = 5000;
mqGetMsgOpts.Options |= MQC.MQGMO_WAIT;
MQMessage mqMsg = new MQMessage();
mqQueue.Get(mqMsg, mqGetMsgOpts);
|
I start App1 to put messages to the queue, then start App2 try to get those messages from the same queue. But App2 gets MQException with reason MQRC_NO_MSG_AVAILABLE.
However, as soon as I stop App1, App2 gets all messages successfully.
What may cause this behavior? How can I fix it so that App2 can get messages while App1 is running?
Realy appreciate your help. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Feb 25, 2009 3:20 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Look at syncpointing...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
gbaddeley |
Posted: Wed Feb 25, 2009 3:32 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
Shouldn't the options be around the other way, ie. to put messages requires MQOO_OUTPUT and to get messages requires one of the MQOO_INPUT_xxx options.
fjb_saper suggests that the messages being put are not committed (ie. not available to be got by other apps) until the connection is closed. You need to explictly commit after putting each message, or don't use syncpointing. _________________ Glenn |
|
Back to top |
|
 |
XianWeng |
Posted: Thu Feb 26, 2009 3:49 pm Post subject: |
|
|
Newbie
Joined: 25 Feb 2009 Posts: 2
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|