• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
  • Piet Souris
  • Mikalai Zaikin

ConnectionPool or resource-ref for JMS connection for P2P in WAS

Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is for a P2P application deployed in WebSphere 5.1.x.

I want to make sure that queueconnections are obtained from a pool and returned to pool.

I see 2 alternative approaches - one with connectionpooling, another with resource-ref.

ConnectionPooling Approach:

1) While configuring queueconnectionfactory in server, we can configure connectionpool.
2) For each message, do following:

- Create QueueConnection.
- Send Message
- Close QueueSession
- Close QueueConnection.

Code is:
try {
qConnection = qConnectionFactory.createQueueConnection();
qSession = qConnection.createQueueSession
sender = qSession.createSender(queue);
message = qSession.createTextMessage();
} finally {

Is the approach above fine for sending message from POJO?

resource-ref approach under:

In resourece-ref approach, I see creating connectionFactory, but I do not see closing it.

InitialContext ctx = new InitialContext();
QueueConnectionFactory qcf_final = (QueueConnectionFactory)
Queue queue_final = (Queue) ctx.lookup("java:comp/env/jms/QueueFinal");

QueueConnection queue_conn = qcf_final.createQueueConnection();
QueueSession queue_session =queue_conn.createQueueSession(false,
QueueSender queue_sender = queue_session.createSender(queue_final);

TextMessage message = queue_session.createTextMessage();
message.setText("This message is from MDB MessageBeanFirst ");

In ejb-jar.xml, add the following lines to the end of the MDB declaration (under the <message-driven> element):


Which alternative (connection pool, or resource-ref) is the correct approach?

Is it not necessary to close connection if resource-ref approach is taken?

Is it fine to use connectionPool approach if message is sent from POJO?
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic