Is it possibly to somehow get notified that the durable function as been or about to be terminated, such that it is possibly to initiate cleanup of the already finished activity functions for example? In my example we're sending multiple requests to a subsystem and need to revoke or refund the orders in case of the durable function is being terminated.
I don't believe that there is any way to subscribe to Terminatation events in Durable Functions, as the Durable Task Framework handles this before user code is ever invoked.
One option instead of using the explicit terminate API built into Durable Functions is to instead listen to some
CustomTerminate
event within your orchestration, using aTask.WhenAny()
approach whenever you schedule an activity or suborchestration. Then, if you ever receive thisCustomTerminate
event instead of the Activity or SubOrchestration response, you could manually handle the cleanup at this point.