Author |
Message
|
JohnRodey |
Posted: Thu Jul 21, 2005 10:17 am Post subject: Pooling JMS Connections |
|
|
 Centurion
Joined: 13 Apr 2005 Posts: 103
|
Does anyone know if it is possible to pool JMS connections to MQ without the use of an app server.
I noticed that there is a setting in the jndi qcf context to "useconnpooling" although this is by default set to yes, and it doesn't seem to enhance performance.
Since it is very expensive to create new connections does MQ offer a way to pool these connections?
I looked through the Using Java guide and only saw info on Java base being pooled. Any help is appreciated. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 21, 2005 10:20 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Look at the Application Server Facilities documentation in the Using Java manual. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Jul 21, 2005 12:10 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You could write your own pooling logic that would need to implement the J2EE resource pooling contract.
Quite a task.
Alternatives: Do not close the connections open and close the sessions.
Keep a number of connections at the ready in a custom pool and use specific logic when it is returned to the pool. However unless you go the J2EE route this will mean changes in your code...
Enjoy  |
|
Back to top |
|
 |
JohnRodey |
Posted: Thu Nov 17, 2005 12:11 pm Post subject: |
|
|
 Centurion
Joined: 13 Apr 2005 Posts: 103
|
Jeff, ...or to anyone who can help =)
What I want to do is be able to do send()'s and receive()'s through JMS (no app servers) without having to create a connection to MQ everytime, or ever for that matter. I would like my code to say "get me a connection from a pool" rather then "create me connection".
I looked into the Application Server Facilities and the sample applications. The sample applications only show how to create an application that acts like an MDB. This isn't the functionality I am looking for. The Load1.java application, which is more like the logic that I want to add connection pooling to, simply creates a connection. Is there any examples of how to aquire this functionality? Is it possible?
Thanks for any help!!! |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 17, 2005 12:21 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Your app is going to have to create a connection at some point - at least one - no matter what.
There's no way, that I know of, to "store" an active connection while your application is not running. The only way to do it is to have some piece of code initialize connections, and then stay running. Then you can retrieve a connection, use it, and give it back to the pool.
It gets even more complicated, and may not be possible, to pass a connection between processes. So you can't have one process make connections, and then hand those connections over to another process.
The only thing you can do is create a long running delegate, that will act as your sender/receiver, and merely exchange data with your application, rather than connections.
But that's a lot like "acting like an MDB", and you said you don't want that.
If you consider the source of Load1.java, and you consider having it create multiple conenctions at start, and then store those connections in a collection, and then adding methods to fetch a free connection from the collection and then add it back to the collection... Then you start rewriting some of the things that are already available through the Application Server Facilities... and why reinvent the wheel? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
JohnRodey |
Posted: Thu Nov 17, 2005 12:47 pm Post subject: |
|
|
 Centurion
Joined: 13 Apr 2005 Posts: 103
|
So if I have applications that send requests to services to do work and wait for a response could ASF be of any assistance?
The only side I care about is the requestor side. The services are always running and talking to the same QM, so they can simply hold their connections forever so performance isnt an issue there.
The ASF samples only show examples of OnMessage applications (MDBs) making use of receiving messages, not sending.
These requestors might only have to send one message, and even if they have to send more than one they might be sending to multiple QM's. The requestors are coming up and down all the time.
So is ASF useful in my scenario? It seems like ASF (at least one of its main features) is for creating a pool of MDBs. correct or no?
Thanks Jeff! |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Nov 17, 2005 2:15 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
From what I recall from the last time I looked at it, the ASF provided a general purpose connection pool.
Let me reiterate a bit about my earlier point though. If your "services" are running all the time, and your "requesters" are starting and stopping, then they are in different processes. And you can't share connections between processes.
So you will have to essentially invoke the service by establishing your own connection to the service, and then passing all of your data to the service... which is not necessarily going to be any faster or cheaper than an MQ connection followed by an MQ Put.
What type of thing is initiating the requestor? Maybe you should look at building a tighter integration between the requestor invoker and the services. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|