• Post Reply Bookmark Topic Watch Topic
  • New Topic

Open, Close Connection for JMS - Connection Pooling  RSS feed

 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a POJO to send messages to a queue in a P2P application. The is maintained by MQ Series. Application is deployed in WebSphere.

Pseuco code is like:

For each message, do following:

1) Create QueueConnection.
2) Send Message
3) Close QueueSession
4) Close QueueConnection.

Above 4 steps take place for each message to be sent to queue.

I have seen a code like this in production also.

My question is, if connection is opened and closed for each and every message to be sent, does it mean that connection pooling is not done in JMS?

I have done WAS server configurations for JMS and you can set connection pooling parameters in WAS server level.

However, the Java code by itself takes me by suprise when I see connection opened and closed for each and every message.

Or, am I missing something?
 
Scott Selikoff
author
Bartender
Posts: 4081
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is one of the reasons WAS encourages resource references instead of direct database/queue access. You can create a resource reference (or in the case of queues a special resource-env ref) and define on it whether or not the connection is shareable.

Then, your application will still create/close connections when sending to the queue but the connections, once freed, will be immediately available to other applications in the connection pool. The driver knows not to recreate new connections that are not needed, the application code does not need to worry.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!