0

Using Azure Durable Functions, and I have a quick question about how the replay logic would work. Let's say within my function, I use an object that implements IDisposable like this:

using (PersonalObject obj = new PersonalObject()){
   // Some random code here
}

Sometimes Durable functions will replay. During the replay logic, will the personal object be created new every single time? Will the disposable object from the previous function get flushed before every replay?

idude
  • 4,654
  • 8
  • 35
  • 49
  • The answer is, it depends. During the `replay`, if the code tries to call a function (or do any other async work), the Durable Task Framework consults the execution history of the current orchestration. If it finds that the activity function has already executed and yielded a result, it replays that function's result and the orchestrator code continues to run. `Replay` continues until the function code is finished or until it has scheduled new async work. In order for the replay pattern to work correctly and reliably, orchestrator function code must be `deterministic`. – Harshita Singh Sep 23 '20 at 10:29

1 Answers1

0

Durable functions will 'replay' orchestrations. Activities are only 'executed again" when a previous run had errors before. Once your activity function has executed successfully it's result is stored and will picked in a replay so no further execution will happen. So it is safe to use disposable objects in an activity function. They should not be used in orchestration functions.

(see my answer to your other question why they should not) What happens to Durable Functions After Activity Function gets called?

Sebastian Achatz
  • 668
  • 4
  • 14