cancel
Showing results for 
Search instead for 
Did you mean: 

Rollback to previous state

galapea
Champ in-the-making
Champ in-the-making
Hello,
I have a service task of type camel. My route using camel default error handler.
If there is error in the camel route, it is always proceeds to the receive task.
How to make the execution rollback to the previous state (service task) ?

I need this to monitor if there is error in some process, then i can signal the process starting from the service task (retry).
I'm using Activiti version 5.16.
Attached the unit test.
5 REPLIES 5

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I am not camel expert, but I wil try to help. In your case

  protected void handleCamelException(Exchange exchange) {
    Exception camelException = exchange.getException();
    boolean notHandledByCamel = exchange.isFailed() && camelException != null;
    if (notHandledByCamel) {
      throw new ActivitiException("Unhandled exception on camel route", camelException);
    }
  }

Do not throw exception, because exception is handled by camel and that's why no activiti exception is thrown. It causes that transaction is not rolled back.
When you want to keep process instance in service task after exception thrown:
1. make service task asynchronous (to rollback transaction to service task only)
2. do not handle camel exception (I would need more investigation how to do that.)

Regards
Martin

galapea
Champ in-the-making
Champ in-the-making
Thanks Martin for your feedback.
Is this <code>activiti:async="true"</code> what do you mean to make service task asynchronous?

martin_grofcik
Confirmed Champ
Confirmed Champ
Yes.

galapea
Champ in-the-making
Champ in-the-making
Sorry, this is not the solution.
<s>Finally it's working now by using <b>ExchangePattern.InOut</b></s>

Using InOut making the process never reach "receiveTask".

smirzai
Champ on-the-rise
Champ on-the-rise
I have created a pull request for this exact problem.
https://github.com/Activiti/Activiti/pull/400

It is waiting to be checked and merged.

If you use this patch, you can throw a BPMNError and deal with in BPMN diagram using a boundary catch exception event.