Configure Bean-Managed Transactions
32.1.2. Using Bean-Managed Transactions Message-driven beans can also be configured to use Bean-Managed Transactions (BMT). In this case a User Transaction is created. This would be configured as follows: @MessageDriven(name = "MDB_BMPExample", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"), @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Dups-ok-acknowledge") }) @TransactionManagement(value= TransactionManagementType.BEAN) @ResourceAdapter("hornetq-ra.rar") public class MDB_BMPExample implements MessageListener { public void onMessage(Message message) } When using Bean-Managed Transactions the message delivery to the MDB will occur outside the scope of the user transaction and use the acknowledge mode specified by the user with the acknowledgeMode property. There are only 2 acceptable values for this Auto-acknowledge and Dups-ok-acknowledge. Please note that because the message delivery is outside the scope of the transaction a failure within the MDB will not cause the message to be redelivered. A user would control the lifecycle of the transaction something like the following: @Resource MessageDrivenContext ctx; public void onMessage(Message message) { UserTransaction tx; try { TextMessage textMessage = (TextMessage)message; String text = textMessage.getText(); UserTransaction tx = ctx.getUserTransaction(); tx.begin(); //do some stuff within the transaction tx.commit(); } catch (Exception e) { tx.rollback(); } }