cancel
Showing results for 
Search instead for 
Did you mean: 

Transaction Management: no rollback?

gant
Champ in-the-making
Champ in-the-making
Hi,

I try to figure out how transaction management exactly works.

I have a process model like this:
startEvent->receiveTask1->ServiceTask->endEvent.

In my 'ServiceTask' I call a spring-wired service that throws an Exception. According to the default Transaction Mgmt Strategy described here: http://www.activiti.org/userguide/index.html#asyncContinuations, I'd expect that the transaction would be rolled back and


Map<String, Object> vars = new HashMap<String, Object>();
       vars.put("exceptionService", new ExceptionThrowingService());
      String processInstanceId = runtimeService.startProcessInstanceByKey("errorHandlingErrorNoBoundaryEvent", vars).getId();
      runtimeService.signal(processInstanceId);
assertNotNull(runtimeService.createExecutionQuery().processInstanceId(processInstanceId).activityId("receiveTask1").singleResult());

in my JUnit test would evaluate to true.

Instead, runtimeService#signal crashes with an 'ActivitiException: Error while evaluating expressions'. What I caused by throwing an exception in my service.

So why is this transaction not rolled back?

I'm using Activiti 5.6

Regards,
michael
1 REPLY 1

trademak
Star Contributor
Star Contributor
Hi,

It's correct behavior that the signal method throws an ActivitiException.
If you catch the ActivitiException the last line in your unit test should still be valid.
So the transaction is rolled back as expected.

Best regards,