Author |
Message
|
marwa |
Posted: Tue Mar 10, 2009 5:21 am Post subject: C Api / Repetitive MQCONN / MQDISC |
|
|
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 |
|
 |
zpat |
Posted: Tue Mar 10, 2009 5:34 am Post subject: |
|
|
 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 |
|
 |
Mr Butcher |
Posted: Tue Mar 10, 2009 5:35 am Post subject: |
|
|
 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 |
|
 |
marwa |
Posted: Tue Mar 10, 2009 5:57 am Post subject: |
|
|
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 |
|
 |
Vitor |
Posted: Tue Mar 10, 2009 6:14 am Post subject: |
|
|
 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 |
|
 |
marwa |
Posted: Tue Mar 10, 2009 11:21 am Post subject: |
|
|
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 |
|
 |
Vitor |
Posted: Tue Mar 10, 2009 1:55 pm Post subject: |
|
|
 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 |
|
 |
|