I read on the Wiki that the JCA-managed connection factory caches connections, so is it ok to simply open and close a connection for each message ?
It is okay if you use JmsXA which is the JCA adapter for JMS, but if you use a regular JMS Connection if you open/close your connection on every send you will have serious performance problems.
I don't know any links.. (besides what you would find with a google search on wiki.jboss.org). But this caching thing is pretty much what I can think now as a best practice on Connections.
I believe you will find a FAQ on JBM about Spring, as it produces messages by closing and opening a JMS connection on every send.
How do I make sure I am using that JCA based connection factory ?
Is its JNDI name java:/JmsXA ?
Does the JNDI name ConnectionFactory map to it ?
You just have to use java:/JmsXA in your JNDI (I'm not sure about the JNDI URL in top of my head now, please google for the right one :-) )
The JCA is defined by the JCA adapter, usually on jms-ds.xml (unless you changed it in your config).
Look for this:
<tx-connection-factory> <jndi-name>JmsXA</jndi-name> <xa-transaction/> <rar-name>jms-ra.rar</rar-name> <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition> <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property> <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property> <max-pool-size>20</max-pool-size> <security-domain-and-application>JmsXARealm</security-domain-and-application> </tx-connection-factory>
Pretty much all the info you have asked for is available on the wiki. Please have a look.
I did check out the Wiki AND the JBM documentation, but there are still some open points for me.
The page that discusses the issue of JmsTemplates and connection open/close says to use the JCA-managed connection factory with JNDI name java:/JmsXA.
Now, when I look at chapter 6.7 of the JBM user guide (http://www.jboss.org/file-access/default/members/jbossmessaging/freezone/docs/userguide-1.4.0.SP3/html/configuration.html#conf.connectionfactory), it mentions JNDI names ConnectionFactory and XAConnectionFactory, but says nothing about whether these global namespace JNDI names actually map or not to a JCA-managed connection factory such as java:/JmsXA.