I am running JBoss 4.2.3 with JBoss Messaging 1.4.2.GA-SP1
This is related to Container Managed Transactions and handling Application Exceptions within EJBs and MDBs.
The following are the exceptions I use:
MyRetryException - Extends Exception
MyEJBRetryRuntimeException - Extends Runtime Exception. Annotated with @ApplicationException ( rollback = false )
The following represents a scenario I am testing.
public class myMDB implements MessageListener { @EJB MyEJB myEJB; public void onMessage( Message msg ) { try { myEJB.process(); // uses the transaction from the MDB } catch ( MyEJBRetryRuntimeException e ) { myEJB.handleException( e ); // starts a new transaction throw e; // I want this message to be redelivered } } }
@TransactionAttribute( TransactionAttributeType.SUPPORTS ) public void process() { try { throw new MyRetryException ("test"); } catch ( MyRetryException e ) { throw new MyEJBRetryRuntimeException(e); } } @TransactionAttribute( TransactionAttributeType.REQUIRES_NEW ) public void handleException( Exception ex ) { Connection conn = datasource.getConnection(); <-- throws an exception. }