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 » QM Connection Status in C++

Post new topic  Reply to topic
 QM Connection Status in C++ « View previous topic :: View next topic » 
Author Message
PeterPotkay
PostPosted: Thu Jul 28, 2005 8:48 am    Post subject: QM Connection Status in C++ Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Thu Jul 28, 2005 8:58 am    Post subject: Reply with quote

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
View user's profile Send private message
PeterPotkay
PostPosted: Thu Jul 28, 2005 9:07 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Thu Jul 28, 2005 9:15 am    Post subject: Reply with quote

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
View user's profile Send private message
PeterPotkay
PostPosted: Thu Jul 28, 2005 9:20 am    Post subject: Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Thu Jul 28, 2005 9:23 am    Post subject: Reply with quote

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
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 » QM Connection Status in C++
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.