views:

25

answers:

0

Hi, I have a JSE application which currently uses JMS, it was written by a developer which is no longer with the company. For some reason, I really don't know if it was justified or not, the JMS session were not created as transacted. I now want to change this as to have all Producers using transacted sessions; This in itself is very simple and I was able to do it but then I encountered my real problem/dillema: I think the current implementation is wrong.
MyProducer is built so it encapsulates a javax.jms.MessageProducer instance and a QFactory instance.
The QFactory is an in-house class which upon request generates a new instance of com.sun.messaging.ConnectionFactory which generates a new instance of javax.jms.Connection which in turn generates a new instance of javax.jms.Session.
This request should be called upon initialization of the MyProducer.
My concrete answers are: 1. How expensive is the creation of the com.sun.messaging.ConnectionFactory?? (I know that in hibernate the SessionFactory is very expensive and they recommend you create only one per JVM) 2. Has anyone seen/tried to use the JMS in a JSE with the ThreadLocal<Session> pattern? So when I commit a session it commits all relevant messages created in this unit of work.

Thanks, Ittai