|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
how to share one ImqQueueManager among multi-processes app? |
« View previous topic :: View next topic » |
Author |
Message
|
caijc |
Posted: Mon Nov 03, 2008 12:41 am Post subject: how to share one ImqQueueManager among multi-processes app? |
|
|
Newbie
Joined: 31 Oct 2008 Posts: 4
|
I'm using c++ on AIX.I opened a connection ,then fork() to create many child processes,each gets the ImqQueueManager as a parameter,then open the same queue,R/S messages.but except the 1st child,the others always return 2020 on ImqQueue.receive.How to do?? |
|
Back to top |
|
 |
David.Partridge |
Posted: Mon Nov 03, 2008 12:50 am Post subject: |
|
|
 Master
Joined: 28 Jun 2001 Posts: 249
|
An ImqQueueManager object is no more than a wrapper on an QM HCONN. An HCONN is only valid within one process, and unless special options are used on the connect request, only one thread within that process.
You need instantiate the ImqQueueManager objects *after* you've forked, not before. _________________ Cheers,
David C. Partridge |
|
Back to top |
|
 |
caijc |
Posted: Mon Nov 03, 2008 12:53 am Post subject: |
|
|
Newbie
Joined: 31 Oct 2008 Posts: 4
|
but connecting with each child-process is so resource-costing that I cannot endure...Could you tell me any other "better" tricks? |
|
Back to top |
|
 |
Vitor |
Posted: Mon Nov 03, 2008 2:40 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
caijc wrote: |
but connecting with each child-process is so resource-costing that I cannot endure...Could you tell me any other "better" tricks? |
Perhaps if you gave us an insight into your design, and why you started where you have, we could offer some advice? As you've discovered the queue manager connection is a very heavy opperation. Typically you'd have one such connection per app, with as many queues in use as you needed, though as pointed out there are thread issues. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
caijc |
Posted: Mon Nov 03, 2008 2:57 am Post subject: |
|
|
Newbie
Joined: 31 Oct 2008 Posts: 4
|
Well,my design is very simple.It's a server,connecting to a QM,to open a send-queue and recv-queue.if any msg arrives on recv-q,it forks a new child process to deal with it.Once the deal is over,the child process should send the result back to the QM through the send-queue.That's all.So,the code is like :
main()
{
qm.connect();
qm.openq(sendq);
qm.openq(recvq);
while(1)
{
buff = qm.receive();
if(fork() == 0)
{
buff = dosomething();
qm.send(buff);
}
}
That's all.so I must/have to build the connection from the beginning,even open the queues at the same time.Any idea??? |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Nov 03, 2008 3:41 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Keep one thread with the connections. Fork with the message content. Pass the reply back to the thread that has the connection for it to do the put...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|