Monolith process to micro service (HELP)

My use case is to have a multi sub process with tasks (another sub process, service …) before and afters. Plus compensation on all elements. What i’m expecting for the compensation is when:

  1. An error occurs during the loop of one of the sub processes (stop the loop and compensate all completed items) + compensate all tasks before in reverse order
    1.1 Alternative (acceptable if 1. is not possible), wait all items complete (error or success) and compensate all if one is in error without added a variable state (must be a feature from the engine) + compensate all tasks before in reverse order
  2. An error occurs after the sub process (compensate all items of the sub process) + compensate all tasks before in reverse order

Edited

@Niall

Hope my last updated post (just before) and the project help you to understand what i want to accomplish.

Have you find a successul way to do it ?