I'm trying to send/produce JMS messages from a simple Stateless EJB. For this I'm using CDI to produce and inject the JMS resources (ConnectionFactory
, Connection
and Session
). Exactly as described in the Weld doc - JavaEE integration, JMS enpoints.
The point is if I produce the JMS Session as trasacted
the ,message is not sent (or commited) by my EJB. No error occurs.
CDI Resource producer:
@Produces
@ItemQualifier
public Session createJMSSession(@ItemQualifier Connection connection) throws JMSException {
return connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
}
EJB JMS producer method:
public void pushItem(Item newItem) throws Exception {
log.info("Sending " + newItem.getDescricao());
log.info("Session Transacted? " + mineracaoSession.getTransacted());
ObjectMessage message = session.createObjectMessage();
message.setObject(newItem);
producer.send(message);
log.info("Message sent!");
}
If I change the Producer method to create non-transacted JMS Session the messages is sent (commited) normally.
I would like to understand why my EJB does not send/commit messages when the JMS session is transacted
. All EJB methods is by default transacted, right?