4
votes

Documentation says:

Reminders are a mechanism to trigger persistent callbacks on an actor at specified times. Their functionality is similar to timers. But unlike timers, reminders are triggered under all circumstances until the actor explicitly unregisters them or the actor is explicitly deleted. Specifically, reminders are triggered across actor deactivations and failovers because the Actors runtime persists information about the actor's reminders.

Let's say we have a reminder set to run after 1h, but the Actor has an idle timeout of 10 minutes and scan interval of, say 2 minutes (set in the actor's ActorGarbageCollectionSettings).

What happens after the first 15 minutes the Actor is idle so is GC'd and deactivated.. so how does it know to recreate the actor 45minutes later? And how does it know what actor ID to use to create the Actor with?

Asking becasue I am wondering how these patterns work:

https://www.codit.eu/blog/2016/08/25/how-to-enable-automatic-scheduling-in-service-fabric-actors/

https://dajbych.net/azure-service-fabric-scheduled-tasks

1

1 Answers

3
votes

Let's say we have a reminder set to run after 1h, but the Actor has an idle timeout of 10 minutes and scan interval of, say 2 minutes (set in the actor's ActorGarbageCollectionSettings).

What happens after the first 15 minutes the Actor is idle so is GC'd and deactivated..

What happens is that the actor is automatically activated when needed by Azure Service Fabric and de reminder code is executed. Using the events and virtual methods provided by the actor framework (OnActivateAsync / OnDeactivateAsync) this is easy to track. In fact, I have a repo that shows exactly that using the EventSource based logging mechanism.

As to how ASF actually tracks the timers and reminders we can only guess, they are open sourcing the project so maybe you can already look it up at the source code.

EDIT: I see it uses a timer internally, see https://github.com/Azure/service-fabric-services-and-actors-dotnet/blob/develop/src/Microsoft.ServiceFabric.Actors/Runtime/ActorReminder.cs

There is an ActorManager that keeps track of all reminders of a specific ActorId in a ConcurrentDictionary.

Edit 2: it is explicitly stated in the docs you added in your question:

Reminders are a mechanism to trigger persistent callbacks on an actor at specified times. Their functionality is similar to timers. But unlike timers, reminders are triggered under all circumstances until the actor explicitly unregisters them or the actor is explicitly deleted. Specifically, reminders are triggered across actor deactivations and failovers because the Actors runtime persists information about the actor's reminders.