|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Parallel connections to several Queues with MQ-API in Java |
« View previous topic :: View next topic » |
Author |
Message
|
raptor |
Posted: Tue Jun 12, 2012 7:35 am Post subject: Parallel connections to several Queues with MQ-API in Java |
|
|
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 |
|
 |
mqjeff |
Posted: Tue Jun 12, 2012 8:05 am Post subject: |
|
|
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 |
|
 |
raptor |
Posted: Tue Jun 12, 2012 8:45 am Post subject: |
|
|
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 |
|
 |
mqjeff |
Posted: Tue Jun 12, 2012 8:54 am Post subject: |
|
|
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 |
|
 |
raptor |
Posted: Wed Jun 13, 2012 6:50 am Post subject: |
|
|
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 |
|
 |
|
|
 |
|
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
|
|
|
|