JMS connection - should I keep it open?

A

Alex Molochnikov

My app sends a heartbeat-type message to a JMS topic connection once a
minute. What is the best strategy for opening/closing the connection:

1. Create the connection, topic session and publisher just before the
message is sent, after that immediately close it, or

2. Create these objects once, and keep them for the app's lifetime.

I did some time measurements in JBoss, using System.currentTimeMillis(), but
at the millisecond level the time consumption is measurable only in
connectionFactory.createTopicConnection() and
connection.createTopicSession() calls (some 16 ms each on my machine).

What are the effects of keeping the connection open forever? Is is akin the
data source connection (i.e. limited communal resource, not to be
squandered)?

Any clues are greatly appreciated.

Alex Molochnikov
Gestalt Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top