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 » C Api / Repetitive MQCONN / MQDISC

Post new topic  Reply to topic
 C Api / Repetitive MQCONN / MQDISC « View previous topic :: View next topic » 
Author Message
marwa
PostPosted: Tue Mar 10, 2009 5:21 am    Post subject: C Api / Repetitive MQCONN / MQDISC Reply with quote

Newbie

Joined: 10 Mar 2009
Posts: 3

I have developped a long running (24/365) C application running on aix . this application receive events from another application ( via tcp sockets ) and at each event it send a mq message to a legacy application.

In my application and at each mq message sending , i code classic pattern : MQCONN - MQOPEN , MQPUT, MQCLOSE, MQDISC.

My questions :
- Is it best practice to repeat MQCONN / MQDISC at each message ?
- Is there a native pooling in MQ when coding in C Api ? ( so MQCONN doens't really create expensive physical connection )
- If I should avoid this repetitive MQCONN/MQDISC , how to code tis application ?
Back to top
View user's profile Send private message
zpat
PostPosted: Tue Mar 10, 2009 5:34 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

No, avoid MQCONN and MQOPEN usage for each message.

Keep connections open as long as possible (all the time is fine).

Keep queues open as long as possible (all the time is fine).

As long as justified by the message volumes (if less than one message per minute then don't bother, if more than one per sec then make every effort to bother).
Back to top
View user's profile Send private message
Mr Butcher
PostPosted: Tue Mar 10, 2009 5:35 am    Post subject: Reply with quote

Padawan

Joined: 23 May 2005
Posts: 1716

Quote:
Is it best practice to repeat MQCONN / MQDISC at each message ?


no

Quote:
If I should avoid this repetitive MQCONN/MQDISC , how to code tis application


Code:

mqconn
mqopen
do forever
   leave when tired :-)
   receive from tcp
   mqput
end do
mqclose
mqdisc


if you use syncpoint option, you need to commit, e.g. after every mqput or after every xxx mqputs, dependiong on what you need
_________________
Regards, Butcher
Back to top
View user's profile Send private message
marwa
PostPosted: Tue Mar 10, 2009 5:57 am    Post subject: Reply with quote

Newbie

Joined: 10 Mar 2009
Posts: 3

My code is slighty diferent :

onTcpEvent
Mqconn
put message
MQdisc

to eliminate Mqconn /MQdisc
should i use a static pointer on queue manger handler created at he first connection ?

How to handle connection lost ?
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Mar 10, 2009 6:14 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

marwa wrote:
should i use a static pointer on queue manger handler created at he first connection ?


Provided it's valid for the thread that's running

marwa wrote:
How to handle connection lost ?


Reconnect.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
marwa
PostPosted: Tue Mar 10, 2009 11:21 am    Post subject: Reply with quote

Newbie

Joined: 10 Mar 2009
Posts: 3

How to detect for a long running application that these objects ( connection, queue manager handler ) are still valid ?

Should getting error ( witch error ) on putting message be useful for this ?
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Mar 10, 2009 1:55 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

marwa wrote:
How to detect for a long running application that these objects ( connection, queue manager handler ) are still valid ?

Should getting error ( witch error ) on putting message be useful for this ?


If you get a 2009 or a 2019 that will indicate that the connection has failed.
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » C Api / Repetitive MQCONN / MQDISC
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.