activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Snyder <>
Subject Re: Best practices with JMS
Date Fri, 04 Mar 2011 17:30:45 GMT
On Fri, Mar 4, 2011 at 10:19 AM, Christian Schneider
<> wrote:
> Hi Filip,
> basically connections can be kept open as long as you like. They are also
> thread safe. For connections there is the problem that they can become
> invalid if the server goes away for too long.
> Sessions can also be kept open but they are not thread safe. So make sure
> you do not share a session between threads.
> I suggest that you take a look at the spring jms abstractions. They help
> with a lot of the problems you may have.
> The keywords you need JmsTemplate, DefaultMessageListenerContainer.
> Be careful though. The spring jmstemplate always closes the connection after
> a request. So you have to use a pooling connection factory. Application
> servers sometimes provide these.
> When doing a standalone application you may want to wrap the connection
> factory in a spring CachingConnectionFactory.
> Frameworks like Camel and CXF use this aproach as it makes life a lot easier
> than working with JMS directly.
> If your focus is on simply sending and receiving your objects in a really
> easy way you might even want to use Apache Camel.
> Messaging canĀ“t be easier than with camel and it embeds nicely in your
> application.

Good suggestions, Christian. I also recommend Spring JMS.

Filip, here are some items I wrote about using Spring JMS with
ActiveMQ that many folks have found useful:

Using Spring to Send JMS Messages:

Using Spring to Receive JMS Messages:

Tuning JMS Message Consumption In Spring:

Hope it helps.

perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"

ActiveMQ in Action:

View raw message