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 » General Discussion » how to share one ImqQueueManager among multi-processes app?

Post new topic  Reply to topic
 how to share one ImqQueueManager among multi-processes app? « View previous topic :: View next topic » 
Author Message
caijc
PostPosted: Mon Nov 03, 2008 12:41 am    Post subject: how to share one ImqQueueManager among multi-processes app? Reply with quote

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
View user's profile Send private message
David.Partridge
PostPosted: Mon Nov 03, 2008 12:50 am    Post subject: Reply with quote

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
View user's profile Send private message
caijc
PostPosted: Mon Nov 03, 2008 12:53 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Mon Nov 03, 2008 2:40 am    Post subject: Reply with quote

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
View user's profile Send private message
caijc
PostPosted: Mon Nov 03, 2008 2:57 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Mon Nov 03, 2008 3:41 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » how to share one ImqQueueManager among multi-processes app?
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.