Workflow timeout and saga compensation

I have a question related to workflow timeout and saga campnsation.

Let’s say I have a workflow which defines a saga object and registers several compensation activities (depending on code path).
The workflow defines a workflow execution timeout.

Is there any way to have the compensation activities invoked even if the workflow timeout expires?

1 Like

Hello @AndreaColombo

Workflow timeout is performed by the server and can not be handled in workflow code

You can use workflow timer to handle business-level timeouts.

      Saga saga = new Saga...;

              result -> {
                return result;

it makes sense.
thanks for the prompt answer

I have one more question, anyway.
Is there any other way to trigger the compensation on workflow timeout without defining the timer within the workflow code? In a way that is “transparent” to the workflow implementation?

Hello @AndreaColombo

You can maybe try putting the logic in listeners instead of in workflow code, not sure if it will work I have not tested it.

But in the end, is still part of the workflow implementation.

You can abstract this behavior in its own utility class or even interceptor.