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 Java / JMS » Parallel connections to several Queues with MQ-API in Java

Post new topic  Reply to topic
 Parallel connections to several Queues with MQ-API in Java « View previous topic :: View next topic » 
Author Message
raptor
PostPosted: Tue Jun 12, 2012 7:35 am    Post subject: Parallel connections to several Queues with MQ-API in Java Reply with quote

Newbie

Joined: 12 Jun 2012
Posts: 3

hi folks,

i´m writing a Java client application with the "native" Java API (no JMS). This application
needs to connect to several Q-Manager and Queues at the same time.
I use the MQEnvironment-Class to setup user-id, password, host, channel, ...
Unfortunately all these elements are static and causing problems with parallel threads.

Do you know an alternative way to set this parameters without using the
MQEnvironment-Class or an other clue to solve my problem?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 12, 2012 8:05 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Please explain exactly and in great detail why you believe you need to connect to more than one queue manager from a single application.

It is in general an anti-pattern to do this.

If you have to consume messages that are produced by applications that connect to several different queue managers, you are supposed to configure MQ to move the messages to the same queue manager, you're not supposed to go get them yourself.
Back to top
View user's profile Send private message
raptor
PostPosted: Tue Jun 12, 2012 8:45 am    Post subject: Reply with quote

Newbie

Joined: 12 Jun 2012
Posts: 3

Because my MQ-Admins don´t want to connect the two Q-Managers. These mangers are
on two different hosts in two different, protected networks. Some applications witch creates
messages for me are on the one machine some are on the other. And all messages must
be handled as fast as possible. Some of them are bigger then 8 MB and take a few
seconds to transmit. Therefore I decided to handle each Queue in a separate thread.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 12, 2012 8:54 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

raptor wrote:
Because my MQ-Admins don´t want to connect the two Q-Managers.


That may or may not be their decision. The question is if their justification for NOT wanting to is outweighed by the business need. There may be a solid business reason for connecting these two networks. There may not.

raptor wrote:
These mangers are
on two different hosts in two different, protected networks.

Okay. That's potentially a legitimate reason, that you are implementing a security gateway between two protected networks.

raptor wrote:
Some applications witch creates
messages for me are on the one machine some are on the other. And all messages must
be handled as fast as possible. Some of them are bigger then 8 MB and take a few
seconds to transmit. Therefore I decided to handle each Queue in a separate thread.


You can specify the channel name, host name, and port number in one of two ways; either as fields in the MQEnvironment class or as properties of the MQQueueManager object.

You could also wrap the code that populates the MQEnvironment and creates the connection into a synchronized block, but it's better to just set the properties explicitly on the MQQueueManager object.

But, again. If you're only connecting to a single queue manager from each thread, and you aren't moving messages across the disconnected networks, then you should still consider if it's a better case to use more than one instance of your program to process the separate queue managers, rather than mixing things up. You can still use lots of threads in each instance, but they'd all connect to one queue manager. That way, for example, if one of the threads causes your program to entirely abend, you won't stop processing on the other queue manager...
Back to top
View user's profile Send private message
raptor
PostPosted: Wed Jun 13, 2012 6:50 am    Post subject: Reply with quote

Newbie

Joined: 12 Jun 2012
Posts: 3

Thank you mqjeff. I wrapped the MQEnvironment in a synchronized method and saved the
MQQueueManager-Objects in separate containers. Now everything works fine
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 Java / JMS » Parallel connections to several Queues with MQ-API in Java
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.