Handling zeebe eror

I’m trying to simulate saga on zeebe.
This is my process (happy path)

But when ledger entries failed (can be technical error like network hiccup, or functional like invalid ledger account), we must “rollback” (or in saga terms, compensate) transactions.
This means, we need to debit the supplier bank.

If failure occured on “finalize payment” node (e.g. account payable invoice cannot created), we have to compensate previous nodes (which is creating reverse ledger entries, and debit supplier bank).

How do we handle this compensation in zeebe bpmn? Do we have to create many if-else gateways (one for every process) : if success, continue next process, otherwise do rollback, etc?

Thanks

You could put a boundary error event on the task. In that case the service can respond with a BPMN error, and it will take the error path from that event.

You could create a rollback path, and then link into it at the appropriate step from each error event.

1 Like

In a workflow, this pattern can look like this:

image

2 Likes

And Undo A should flow to an end event or some alerting task, right?

Yes, correct. “Undo A” can be connected to an event end or a follow-up task. Here, I omitted it to look more like the normal BPMN compensation pattern (aka SAGA).

OK, Got the idea. Trying to write the code for this

One more question: in the “Debit suplier bank”, this must be done by human, through certain user interface (we manage the UI and backend for debit). How can we achieve this in zeebe?

Thanks for the replies

2 Likes

Currently, Zeebe doesn’t support user tasks. One way to model an user interaction is to use a service task to trigger the UI application and wait for a message that is sent by the UI application when the task is done.

Or you could raise an incident for it by failing the job and setting retries to zero.

An operator then deals with the incident, sets a flag in the payload, resolves the incident, and the “Debit Supplier Banker” worker completes the job when it sees the flag set as the workflow resumes.