|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQOPEN question |
« View previous topic :: View next topic » |
Author |
Message
|
moe |
Posted: Wed Apr 11, 2007 12:32 am Post subject: MQOPEN question |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
Hello Again,
Platform: AIX, Language: C, MQ 5.3 CSD12
In a single threaded C program, within the same function i'm trying to open a local queue using two different MQOPEN calls, one with MQOO_INPUT_SHARED and the other with MQOO_BROWSE.
Each MQOPEN is using the same connection handle, but is using seperate message descriptors, seperate get options (obviously).
However the second MQOPEN call is failing with RC 2019. I've checked throughout the doco and the closest thing to this issue relates to sharing a object handle or connection between several threads and this being done by using MQCONNX with the MQCNO_HANDLE_SHARE_NO_BLOCK option, however I dont think this will fix the issue.
Doco states:
MQRC_HOBJ_ERROR
The object handle Hobj is not valid. If the handle is a shareable handle, the handle may have been made invalid by another thread issuing the MQCLOSE call using that handle. If the handle is a nonshareable handle, the call may have been issued by a thread that did not create the handle. This reason also occurs if the parameter pointer is not valid, or (for the MQOPEN call) points to read-only storage. (It is not always possible to detect parameter pointers that are not valid; if not detected, unpredictable results occur.)
Corrective action: Ensure that a successful MQOPEN call is performed for this object, and that an MQCLOSE call has not already been performed for it. For MQGET and MQPUT calls, also ensure that the handle represents a queue object. Ensure that the handle is being used within its valid scope.
But I havent closed the object the two calls are one after the other:
Code: |
...
MQOPEN(hConn, &odB, oOptionsB, &hObjB, &openCode, &reason);
checkCallResult("Opening xmitQueue for BROWSE", openCode, reason);
MQOPEN(hConn, &odI, oOptionsI, &hObjI, &openCode, &reason);
checkCallResult("Opening xmitQueue for INPUT", openCode, reason);
...
|
 |
|
Back to top |
|
 |
Vitor |
Posted: Wed Apr 11, 2007 12:41 am Post subject: Re: MQOPEN question |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
moe wrote: |
But I havent closed the object the two calls are one after the other:
Code: |
...
MQOPEN(hConn, &odB, oOptionsB, &hObjB, &openCode, &reason);
checkCallResult("Opening xmitQueue for BROWSE", openCode, reason);
MQOPEN(hConn, &odI, oOptionsI, &hObjI, &openCode, &reason);
checkCallResult("Opening xmitQueue for INPUT", openCode, reason);
...
|
 |
In a more general point, you're not really opening an xmitq are you? There's seldom a good reason for an application to do that.
I'm assuming here that odB & odI are separate memory blocks? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
moe |
Posted: Wed Apr 11, 2007 12:48 am Post subject: |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
Ignore the dodgy comments Its really just a regular queue, the code is just a continuation on from my previous attempts (see: http://www.mqseries.net/phpBB2/viewtopic.php?p=174188#174188).
odI and odB are declared as seperate variables, here are the declarations:
Code: |
MQOD odB = {MQOD_DEFAULT};
MQOD odI = {MQOD_DEFAULT};
|
The queue name is strncpy'd into odI.ObjectName before the MQOPEN. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Apr 11, 2007 1:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
The same of course is true for the queue handle objects? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
moe |
Posted: Wed Apr 11, 2007 2:48 am Post subject: |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
|
Back to top |
|
 |
wschutz |
Posted: Wed Apr 11, 2007 5:48 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
any reason you just don't do a single open specifying MQOO_INPUT_SHARED + BROWSE? _________________ -wayne |
|
Back to top |
|
 |
moe |
Posted: Wed Apr 11, 2007 3:57 pm Post subject: |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
Im only interested in messages with a particular string inside them, how would combining MQOO_INPUT_SHARED + BROWSE work, wouldnt the BROWSE options always be overruled by the input shared? I mean everytime I do a get will the message remain on the queue or will it be popped off?
Basically i'm using one object handle to browse for the target message, then using the other to pop it off the queue, when I MQGET the message using the INPUT object handle then I use the MQMO_MATCH_MSG_ID match option.
Here are some code snippets (sorry I should've included this earlier)
Code: |
MQOD odB = {MQOD_DEFAULT};
MQOD odI = {MQOD_DEFAULT};
MQMD mdB = {MQMD_DEFAULT};
MQMD mdI = {MQMD_DEFAULT};
MQGMO gmoB = {MQGMO_DEFAULT};
MQGMO gmoI = {MQGMO_DEFAULT};
MQHOBJ hObjB;
MQHOBJ hObjI;
MQLONG oOptionsB;
MQLONG oOptionsI;
MQLONG compCode;
MQLONG openCode;
...
oOptionsI = MQOO_INPUT_SHARED;
oOptionsB = MQOO_BROWSE;
mdB.Version = MQMD_VERSION_2;
mdI.Version = MQMD_VERSION_2;
strncpy(odI.ObjectName, c->queueName, (size_t)MQ_Q_NAME_LENGTH);
strncpy(odB.ObjectName, c->queueName, (size_t)MQ_Q_NAME_LENGTH);
....
MQOPEN(hConn, &odB, oOptionsB, &hObjB, &openCode, &reason);
MQOPEN(hConn, &odI, oOptionsI, &hObjI, &openCode, &reason);
...
MQGET(hConn, hObjB, &mdB, &gmoB, bufLen, pBuffer, &messlen, &compCode, &reason);
/* I check the buffer for the presence of a particular string */
MQGET(hConn, hObjI, &mdI, &gmoI, bufLen, pBuffer, &messlen, &compCode, &reason);
/* Do more with the target message */
|
|
|
Back to top |
|
 |
kevinf2349 |
Posted: Wed Apr 11, 2007 7:44 pm Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
What you are trying to do could (and some would argue should) be done as Wayne suggests....using just one object handle. Use browse the find the required message and then delete it using the get_msg_under_cursor option.
The technique you are trying to use is destined to end in tears
The APG(?) has a section on doing exactly what you are trying to do. |
|
Back to top |
|
 |
moe |
Posted: Wed Apr 11, 2007 8:26 pm Post subject: |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
Well, not exactly tears but hours and hours and HOURS of browsing doco to no avail, debugging with little more than printf statements, however i'm working on other things right now and will probably get a chance to try this later today sometime...thanks everyone  |
|
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
|
|
|
|