Whatever threw the exception caused the transaction context into rollback only mode. When onMessage returns all transactional resources will be called to rollback. This includes the datasource used for the prepared statement in someUpdateMethod().
To get the update committed it must be executed in a separate transaction. Do this by calling another stateless session bean with the @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) on the method.
@MessageDriven(...
public class MyMdb inpelements MessageListener
@EJB
Updater updater;
@Override
public void onMessage(Message message) {
try {
someMethod();
}
catch(Throwable o) {
updater.someUpdateMethod();
}
}
}
The stateless session EJB that executes the update in a separate transaction.
@Stateless
public class Updater {
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public String someUpdateMethod() {
//update query runs here
}
}