Does anyone know if I have a method that has a transactional attribute of propergation=REQUIRED_NEW why it doesn't start in a new transaction? I have a method that is already running in a tx which calls other methods one of which is a method with REQUIRED_NEW attribute in the finally block. This however does not seem to want to start a new tx. This causes a problem when an exception is raised because the status updates that indciate a failed status get rolled back after the method completes. Any pointer tips would be helpful. Could I use AOP @AfterThrowing at all to perform the functionality if you cannot start a transaction in the finally block? And is possible to do it declaratively too? When there are no errors everything works fine.
@Transactional
public void processor(...) {
//start tx1
process feed in a separate thread and transaction. This creates a new transaction for each thread and also commits on thread/completion. This all works.
//tx1 resumed
additional processing performed
status=SUCCESS
catch (Exception e) {
set status=FAILED
throw new AppSpecificException()
}
finally () {
dosomething()
// exect this method to happen in new tx but it doesnt
updateStatus(status)
}
@Transactional(propergation=Propergation.REQUIRED_ NEW)
updateStatus(Status) {
....
}
}


Reply With Quote