Author |
Message
|
thompsa |
Posted: Fri Jan 19, 2007 1:11 am Post subject: amqsbcg exits when calling MQGET with browse options |
|
|
Newbie
Joined: 18 Jan 2007 Posts: 6
|
Hi, I am developing a test program (in VB) for an application using remote queues. I can successfully use MQPUT to submit a message to a queue, but when I try to browse the output queue, the program crashes/exits in the MQGET call.
To ensure it was not my code at all, I have gone back to the amqsbcgb VB sample. The only things I have changed in this sample is the compilation parameter (mtype=2) for remote queues and the MQCONN line to connect to the queue manager I have, rather than the default queue manager as it was coded. Having specified the MQSERVER environment variable, I run the sample and the window opens. I type in the queue name and click Open. This successfully connects and opens the queue (return code 0). The Browse button is then enabled. I then click on Browse and the program exits, window disappears etc. No on screen messages.
Has anyone any clues what is going wrong? |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jan 19, 2007 1:17 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Sounds like a code bug to me.
Any chance the error handler is responding to an MQ reason code by issuing an "End"? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
zpat |
Posted: Fri Jan 19, 2007 1:56 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
You can't open remote queues for input. Are you handing the exception? What is the MQRC? |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jan 19, 2007 2:04 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
zpat wrote: |
You can't open remote queues for input. |
Quite true, but not I suspect what thompsa means. mtype=2 (or MqType as it's more traditionally spelt) is how you select client rather than binding. From this I infer what is meant is "queues that are remote to the box I'm sitting on".
Of course, if there is an attempt to browse a remote queue then I'm with you - it won't work and (as I previously posted) the program may be handling the error in a less than graceful way!  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
thompsa |
Posted: Fri Jan 19, 2007 2:56 am Post subject: |
|
|
Newbie
Joined: 18 Jan 2007 Posts: 6
|
Sorry about the typo - yes I meant mqtype=2 which denotes I am a client. I am connecting to another machine's queue manager (which works OK) and opening a local queue on that queue manager (which works OK). It is only when I call MQGET with the browse options that the program exits. As MQGET never returns, there is no return code.
I can RDP to the box the queue manager is on, and I can use MQ Explorer to browse the queue.
If it's a code problem, it must be code inside MQGET? Surely any error ought to give a useful reponse and error code.
I have seen some posts that indicate browsing may be a bit fraught but a destructive get may work. I don't really want to delete the messages on the queue........
Any more thought appreciated. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jan 19, 2007 3:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
thompsa wrote: |
If it's a code problem, it must be code inside MQGET? Surely any error ought to give a useful reponse and error code. |
It does give useful response and error codes. I (along with the rest of the posters on this forum) can attest to that. Given the number of MQGETs issued through the life of the product, I do hesitate to suspect the IBM code first off....
Have you stepped through the code to prove it doesn't come back from the MQGET? And ensured that any reason codes are properly trapped? I can personally verify what you're trying to do works in VB6 just fine.
thompsa wrote: |
I have seen some posts that indicate browsing may be a bit fraught but a destructive get may work. |
News to me. Get and browse are the same code with different options. Can you posts links to the posts where you've seen this? Certainly I've not expereinced browse being "fraught". Except where someone's got the options wrong and expereinced unexpected results, i.e. it's done what they told it to do not what they wanted it to do. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
thompsa |
Posted: Fri Jan 19, 2007 3:56 am Post subject: |
|
|
Newbie
Joined: 18 Jan 2007 Posts: 6
|
On my test program, I commented out the MQGET and the the next line is executed fine (it writes out a variable to a log file, which would be the return code if the MQGET was executed).
Using amqsbcgb, there is none of my code in there! It is either the sample or the MQGET. I'm not trying to rubbish the MQ code - just to get the browse to work. Alternatively could there be some installation /config issue?
My original hunt was via Google not just this forum, and I don't know where all the things I read are. Repeating what I thought I did came back with this old item:
http://www-1.ibm.com/support/docview.wss?rs=171&uid=swg1IC33324 |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jan 19, 2007 4:07 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
So it used to be a problem on HP in v5.1. That's something I didn't know when I got up this morning...
(Please see my sig below....) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jan 19, 2007 4:12 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
That leads to more relevant questions:
1) What version of MQ are you using, and patched to what level?
2) Is the MQ Client installed on the box you're running on?
I know you've got MQ installed locally as you refer to a local queue manager. Have you also installed the client code?
Another diagnostic - if you use MqType=2, specify your local queue manager in the code and set MQSERVER to point to your local machine, do you get the same result as pointing to the remote queue manager? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
thompsa |
Posted: Fri Jan 19, 2007 7:09 am Post subject: |
|
|
Newbie
Joined: 18 Jan 2007 Posts: 6
|
I didn't do the install of MQ, but here is my understanding from those that did.
The local machine is installed as MQ client only. Version is 6.0.1. You can start MQ Explorer, but no Queue Managers are shown.
The remote machine has the queues (some local and some remote) and has MQ installed also at 6.0.1. I can RDP to that machine, start MQ Explorer, see the Queue Managers and browse the local queue (i.e local to that queue manager) I want.
I could possibly try moving my code to the remote machine to see if it can browse the queue using MqType=1 and/or MqType=2 with MQSERVER set to itself. Is this the best way forward? |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jan 19, 2007 7:20 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You can make sure that the client MQ Explorer can browse the remote queues.
Open MQ Explorer, right click on qmgrs and "Show/Add". Then click Show, and provide connection information for the remote qmgr.
If that works, you know a) there's nothing wrong with the queues, b) there's nothing wrong with the client install.
Pretty much, this is an issue with your code - or it's a bug in the 6.0.1.0 release. You could upgrade the client to 6.0.2.0, or 6.0.1.1 and see if that changes things.
But it's a lot more likely it's a bug in your code. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jan 19, 2007 7:23 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It could also be an issue with binding/packaging your application against the wrong library. You might need to specify NMQ_MQLIB or whatever it is. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
thompsa |
Posted: Fri Jan 19, 2007 7:49 am Post subject: |
|
|
Newbie
Joined: 18 Jan 2007 Posts: 6
|
I've added the remote Queue Manager into MQ Explorer running on the local machine specifying the IP and port, and that has been added fine and I can browse messages in the queue I want. I assume this means the queues and the client are OK.
I am using the supplied amqsbcgb program, unchanged apart from the name of the queue manager and setting compile option MqType=2. I can only assume there is something wrong in the API or in the recompile. I am using VB6.0 version 8176. What is NMQ_MQLIB? |
|
Back to top |
|
 |
Vitor |
Posted: Sun Jan 21, 2007 11:58 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
If there's no queue manager on the actual machine on which you're running the program, you must use MqType=2 and the client bindings. If MqType=1 works in this configuration, you have a serious installation issue!
If you're convinced there's nothing wrong with the code (because you've not made any significant changes to the supplied sample), and the client installation is ok, then you probably need to raise a PMR with IBM and report a bug with the 6.0.1.0 release & see what they say.
Or try a different version as jefflowrey suggests. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
thompsa |
Posted: Tue Jan 23, 2007 2:22 am Post subject: |
|
|
Newbie
Joined: 18 Jan 2007 Posts: 6
|
I think I may have worked out what is going wrong. I am not an expert with VB or MQ, but this is what I found.
Looking at the include file supplied with the VB sample (cmqb.bas), it calls the DLL (MQI32.DLL) by passing the buffer by 'Buffer As String'. My understanding is this passes a pointer to a VB string structure, not a pointer to the string location. I believe the DLL is interpreting this as a buffer, trying to write to it, causing the crash.
I have changed the call in cmqb.bas to 'ByVal Buffer As String' and this seems to do the trick. No crash now, and the first part of the buffer is overwritten with the browse information from the message in the queue. I then do a Left(Buffer,readlen) to get a string with just the message in it.
If I am right, this is therefore a bug in the VB include code, but I seem to be able to do what I need now. It would be interesting to know, if anyone has a later release than 6.0.1, whether this has been fixed in a later release.
Thanks for all the help. |
|
Back to top |
|
 |
|