@Local
public interface TestJob_if {
@Asynchronous @Transactional
public QuartzTriggerHandle doWork();
}
@Stateless
@Name("testJob")
public class TestJob implements TestJob_if {
@In(create = true) private Session session;
public QuartzTriggerHandle doWork() {
BlacklistEntry b = createEntry();
if (true) throw new RuntimeException("fail here...");
return null;
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public BlacklistEntry createEntry() {
BlacklistEntry b = new BlacklistEntry();
b.setBlacklistType(BlacklistType.EMAIL);
b.setField1("some.email@domain.com");
session.persist(b);
return b;
}
}When the exception occurs in the main async method, the entire transaction is rolled back and nothing is committed to the database. I expected the createEntry() function to have executed in a new transaction and to have committed the entry to the database before returning to the parent method. Am I doing something wrong or does this look like a bug in transaction demarcation with async methods?
jboss 2.0.2.GA and jboss 4.2.2.GA