I think you have 2 questions:
You need to make your pojo SLSB. It should be injected into your jms listener, which is not called directly, so you are dealing with a proxy link. It can still be used as a simple pojo, as annotations will be ignored if they are not deployed in the container.
You are creating a jms session using AUTO_ACKNOWLEDGE, but you need to execute it. Also, make sure the jms connection comes from the JCA transaction source, as this will connect the session to the transaction.
========= Update =========
Hey Bill;
Sorry, I thought the external bean was a JMS listener for some reason ..... In any case, the problem is the same.
If you want MailQueueMessenger to behave according to the annotations that you post on it (transactional, injections, etc.), you need to refer to it as an EJB, not a simple pojo. Accordingly, your external bean session should look like this:
@EJB // key difference private EmailQueueMessenger eqm; @TransactionAttribute(TransactionAttributeType.REQUIRED) public void sendMessage(Object messageObject) { eqm.sendEmail(messageObject); }
Now your
@Resource(name = "jms/EmailerQueueConnectionFactory") @Resource(name = "jms/EmailerQueue")
and
@TransactionAttribute(TransactionAttributeType.MANDATORY) @Stateless
annotations will be executed.
Finally, your JMS sender will be registered in the transaction at the point of call, and you need to make sure that the transaction manager knows that you are picking up the second resource manager in the transaction (first the database, and now the JMS). I am not familiar with the glass board, but there seems to be a configuration screen with a switch that allows you to specify the level of transactional support for the factory connection .
I would change the sender code to:
Session session = con.createSession(true, Session.SESSION_TRANSACTED);
Technically, you can cache an instance of a JMS connection in an instance of EmailQueueMessenger. Your code should not close the JMS session, as it will be processed when the transaction completes (although I saw deviations between the JMS / JTA implementations at this point).
I hope this clears, and I really hope it works!