ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Put/get messages to/from the same queue concurrent

Post new topic  Reply to topic
 Put/get messages to/from the same queue concurrent « View previous topic :: View next topic » 
Author Message
XianWeng
PostPosted: Wed Feb 25, 2009 3:11 pm    Post subject: Put/get messages to/from the same queue concurrent Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Wed Feb 25, 2009 3:20 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Look at syncpointing...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
gbaddeley
PostPosted: Wed Feb 25, 2009 3:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
XianWeng
PostPosted: Thu Feb 26, 2009 3:49 pm    Post subject: Reply with quote

Newbie

Joined: 25 Feb 2009
Posts: 2

Thank you!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Put/get messages to/from the same queue concurrent
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.