On Fri, Mar 4, 2011 at 10:19 AM, Christian Schneider
<ch...@die-schneider.net> 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.
> http://camel.apache.org/jms.html
> http://camel.apache.org/pojo-messaging-example.html
> 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:
http://bsnyderblog.blogspot.com/2010/02/using-spring-jmstemplate-to-send-jms.html

Using Spring to Receive JMS Messages:
http://bsnyderblog.blogspot.com/2010/02/using-spring-to-receive-jms-messages.html

Tuning JMS Message Consumption In Spring:
http://bsnyderblog.blogspot.com/2010/05/tuning-jms-message-consumption-in.html

Hope it helps.

Bruce
-- 
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: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Reply via email to