Cancel transaction from external process

Hello,

I was wondering how a transaction should be cancelled by an external process.

Is this the best way to do it? Is it also a correct approach in order to compensate the tasks (e.g. Task 2) in the transaction subprocess?

Thank you.

Hey @hcaballero! :wave:
My recommendation would be to use an event sub process. You can see my approach below:

example1.bpmn (6.6 KB)

But there are also other possibilities to manage something like this :thinking:

1 Like

This could be even a better example for the use-case of yours. Wdyt?
example2.bpmn (13.4 KB)

Thank you very much, @Hafflgav, and sorry for not answering yesterday.

I would have two questions regarding your last diagram:

  • Would the activation of the compensation consume all active tokens? Imagine that the sequence including Task A and Task B was in fact a complicated sequence with many parallel branches.
  • If I created an independent parallel sequence in order to activate the trigger compensation signal instead of using a non-interrupting message event, would it also be adequeate?

Thanks again.

Happy to answer those @hcaballero! :slight_smile:

As far as I remember the compensation event does not interrupt any of the other active tokens. Hence there is the need for a termination end event to make sure that no active tokens are alive anymore.

Can you visualise this? I tend to say “it depends” :smiley:
The benefit of using a non-interrupting message boundary event is that you can handle a couple of more steps when the compensation is received. Especially if you are having a subprocess this comes in handy since you can still operate further outside of the context of the subprocess.

Sure, @Hafflgav.

This is what I mean:

Since you considered a non-interrupting message event, this diagram would be equivalent, wouldn’t it?

The problem I see with not using a transaction with a cancel event is that, if it is so that the compensation does not immediately consume all active tokens, an event that takes place during the compensation could make the process flow advance, even in those cases in which the intention was to stop the process flow, compensate performed activites and end the process.

Regards.

Yes! That would work :slight_smile:

In this case I would rather use a process as described in my first example. If you are having an event subprocess with an interrupting message start event you can stop all tokens in the process and also append some tasks for performing a rollback.

Hi @Hafflgav,

Could you please explain how the activation of the Termination Event (red circle) would consume or force the consumption of all active tokens in the main sequence (green circle) before executing the “Compensate things in a separate task” activity?

By the way, is there anything specific that you deem wrong or inelegant in my proposal?

Thanks a lot.

If you are having an event based subprocess there are two possibilities which can occur.

  1. You have a non interrupting start event which does not influence the execution of the parent process
  2. You have an interrupting start event which stops the execution of the parent process (similar to a termination end event)

Taking a look on your initial proposal: You will actually stop the execution of the subprocess when a message is being received. The compensation though will never happen. In addition no termination end events are needed.

In the second proposal of yours you are only missing some compensation activities which are being connected to your boundary events. Though as pointed out - calling the compensation won’t lead to the process instance being stopped.

1 Like

Thank you, @Hafflgav.

Everything is clear now.

Just one remark… If I am not mistaken, the cancel event will automatically trigger compensation, as explained, for example, here: Cancel and Compensation Events | docs.camunda.org.

Both terminate end events could indeed be none end events, since in this case only one path or the other will be active.

Regards.

1 Like

Oh, that’s awesome! I wasn’t aware of this. Thanks for the info :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.