Author |
Message
|
PeterPotkay |
Posted: Thu Jul 28, 2005 8:48 am Post subject: QM Connection Status in C++ |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
Trying to help an app that is working with vendor that coded their MQ API in C++. Yikes!
The MQClient app wants to proactively check the status of its connection to the QM. I looked in the manual and found that the impQueueManager class has an object attribute called connection status. "True when connected to the QM. This attribute is read only." So I told them to call that whenever they wanted to check if they were connected (once every 30 seconds).
But they came back and said that always comes back as true until they try and MQPUT or MQGET, and only then is the lost connection status realized. So they coded a PUT of a small dummy message every 30 seconds as a test for a live connection. Ack!
Is C++ different in this regard? Is it possible that this attribute of the MQ (is connected) is a cached value that only gets updated if some other action forces a call to the QM? _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 28, 2005 8:58 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
There's no reason to proactively check the status of a connection.
If it fails when you use it, and you know it's okay to retry, then reconnect.
Otherwise deal with the error.
But rather than doing a dummy PUT, they could just as easily and with less overhead do an INQ. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
PeterPotkay |
Posted: Thu Jul 28, 2005 9:07 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
"There's no reason to proactively check the status of a connection."
That is my 1st recomendation to them!
However, if we/they wanted to check the status in C++, how? There is no INQ mentioned in that C++ manual. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 28, 2005 9:15 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
PeterPotkay wrote: |
However, if we/they wanted to check the status in C++, how? There is no INQ mentioned in that C++ manual. |
There are a bunch of methods on ImqQueue that return queue properties (backoutRequeueName, etc). These should do an INQ in the background. The methods seem to come in two flavors - one that returns the requested value directly, and one that returns a boolean and changes a passed in parameter to the requested value. I'd recommend the second. They don't really care about the return value, they just want to know if the method succeeds or not.
So
Code: |
if (myImqQueue.creationTime(&dummyImqString)) {
//then we know it succeeded and the connection is still good |
For example.
Edit: The same type of method is available on ImqQueueManager. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
PeterPotkay |
Posted: Thu Jul 28, 2005 9:20 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
I'll suggest they try that, but who knows, maybe that type of info is also cached the 1st time the q object is opened.
Hmmm, I can't imagine the current depth is a cached value, so I'll ask them to use that value if they insist on proactivly verifying the connection status.
Thanks Jeff. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 28, 2005 9:23 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Also remind them that there is no guaranteed atomicity between this call and their next Get/Put. It could be fine when they check, and fail before they use the connection.
Remind them to treat MQ connections like Database connections, and MQ operations like database operations (but NOT to treat queues like tables!) - if the connection is bad, deal with it and if the operation succeeds, don't double-check it! _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|