I have two stateless SessionBeans. My client (JSF2 application) calls the (saveOrderCompletion) method in the first EJB (CompletionFacade), which calls another method (processRequest) in the second EJB (ContactFacade) to send the message to the queue through the JMS.
At the end of the first method called, I throw a RuntimException to see how JBoss behaves. This must be done in one transaction, so the transaction must roll back so that no message is sent to the queue.
I double-checked this on a weblogic server that shows the exact behavior. My question is why does JBoss not roll back the whole transaction? Did I miss something...
The entity is not saved, but the message is still sent to the queue.
I am using jboss 7.1.1, the application is deployed as an EAR
Here is my beans session ...
@Stateless public class CompletionFacade implements CompletionFacadeRemote, CompletionFacadeLocal { @PersistenceContext(unitName="my_test") private EntityManager entityManager; @EJB ContactFacadeLocal contactFacade; ..... @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public OrderCompletion saveOrderCompletion(OrderCompletion orderCompletion) throws TestBusinessException { try { ...do some stuff on entity
and the second facade:
@Stateless public class ContactFacade implements ContactFacadeRemote, ContactFacadeLocal { .... @TransactionAttribute(TransactionAttributeType.REQUIRED) public void processRequest(Object request, SmtpPartner partner) throws TestGenericException { if (logger.isDebugEnabled()) { logger.debug("Starting to process request!"); } QueueConnection connection = null; QueueSession session = null; try { ...lookup queue etc... sender.send(QUEUE, objectMessage); } catch (JMSException e) { logger.error("MS Exception:", e); } catch (NamingException e) { logger.error("Naming exception:", e); } ... } finally { try { session.close(); connection.close(); } catch (JMSException e) { logger.error("Error closing connection:", e); } } } ... }
Any help is appreciated.
source share