I've answered this in the sticky FAQ topic
Thanks, I really needed that.
The Sticky FAQ does not answer the part of the question if I need to close the TopicConnection and TopicSession myself or if the container will do that if my session bean is container managed.
I would prefer to work with container managed beans since I actually have two session beans that will publish messages and I would like both of them to work in the same transaction. If however, I need to do bean managed transactions to be able to close the jms resources then both beans will start their own UserTransaction...
I will need some more help please.
Now that I am using java:/JmsXA I am getting the following exception when getting a TopicSession:
11:13:59,400 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jms.JmsSession@63b5ed
The code I am using to do this is:
TopicConnection connection = (TopicConnectionFactory) initialContext.lookup("java:/JmsXA");
TopicSession session = connection.createTopicSession(true, TopicSession.SESSION_TRANSACTED);
Why is it closing the connection I just created?
The sessions are pooled behind the scenes. It is like the jdbc connection pool.
You should do the same close to return it to the pool:
// Use resources