[jboss-user] [JBoss Messaging] - Re: Connection caching

timfox do-not-reply at jboss.com
Fri Nov 9 10:42:29 EST 2007


Inside the app server you can use the JBoss JCA resource adapter (the thing at /JmsXA - see the user wiki) for caching sessions.

This is useful when you're for example sending messages from an EJB.

Note that JCA JMS resource adapters do not cache JMS connections, they cache JMS sessions.,

Caching JMS connections won't be much use to you, since you don't want to be creating a new session every time you send a message (slow). Creating a producer every time you send a message (which would happen with JmsXA) is not so bad since mesage producers are typically lightweight objects created only on the client side - although of course there is some overhead even with that.

On the client side the JBoss JMS resource adapter won't work. But then, if you handle connection creation and closing sensibly in your own code there should be no need for caching connections/sessions/consumers.

Personally I dislike these caching layers since they encourage bad programming habits and cover a multitude of sins.

At the end of the day in order to use JMS optimally you need to have a good understanding of the relationship between connection, session, consumer and producer objects and use them appropriately.

You may be able to get something like Jencks to work for you on the client side. AFAIK this is an alternative JCA adapter. But be warned, as mentioned before, these will only cache JMS sessions, so you'll still be creating a producer / consumer each time, and you have to be careful to avoid losing messages due to consumers being transiently created/closed.

My advice, avoid Spring JMSTemplate altogether and don't use caching, apart from on the app server for sending messages (for receiving you could use MDBs)

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4103297#4103297

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4103297



More information about the jboss-user mailing list