dcsimg
Pooling of connections/sessions
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   raja_sekhar
Posted On:   Thursday, October 3, 2002 05:45 AM

Hi I am using JMS in a request/reply scenario. The following is the sequence of operations 1. Get handle to Connection by JNDI lookup of QCF 2. Get handle to RequestQueue by JNDI lookup of Request Queue 3. Get handle to ResponseQueue by JNDI lookup of Response Queue 4. Create a Session and Sender on the Connection/RequestQueue. 5. Create a JMS message and send it with a correlation id on the Sender 6. Create a Session and Reciever on the connection/ResponseQueue with "CorrelationID" as message selector. 7. Receive the JMS message over the reciever. There are multiple threads trying to send and reci   More>>

Hi


I am using JMS in a request/reply scenario.

The following is the sequence of operations


1. Get handle to Connection by JNDI lookup of QCF

2. Get handle to RequestQueue by JNDI lookup of Request Queue

3. Get handle to ResponseQueue by JNDI lookup of Response Queue

4. Create a Session and Sender on the Connection/RequestQueue.

5. Create a JMS message and send it with a correlation id on the Sender

6. Create a Session and Reciever on the connection/ResponseQueue with "CorrelationID" as message selector.

7. Receive the JMS message over the reciever.



There are multiple threads trying to send and recieve messages.
Now my questions are --

1. What all things above can be re-used/pooled? Can I use only connection and create, say, for example 100 sessions and reuse them across 100 different threads?

2. Or Can I reuse the Senders and recievers as well? In other words, can I create 100 senders (or receivers) and reuse them over 100 threads. (In other words can I create a "SenderPool" and use them)

3. How many Sessions can be opened on one Connection?

4. I heard about ServerSessionPool, but did not have any pointers on how to get a handle to a ServerSessionPool? Will this be useful in this scenario?



Any help is highly appreciated,



Thanks and regards,

Rajs

   <<Less

Re: Pooling of connections/sessions

Posted By:   Boaz_Inbal  
Posted On:   Wednesday, October 9, 2002 06:07 AM

You need to follow JMS restriction of Session per Thread.


What I did was implemented my own Session pool per thread and kept them in a hash for future use by the same thread.


For each thread you can create a Sender/Receiver by using the session.


Each thread has a unique key by its name and each session is attached to a thread.


With another paameter (e.g. opCode) you can create a Sender per Session and hold it as well for future use.


Other objects - QueueConnectionFactory/QueueConnection are created once.


Hope it helps.
About | Sitemap | Contact