简体   繁体   English

Service Fabric 提醒

[英]Service Fabric Reminders

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.具体来说,由于 Actors 运行时会保留有关参与者提醒的信息,因此在参与者停用和故障转移时会触发提醒。

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 ).假设我们将提醒设置为在 1 小时后运行,但 Actor 的空闲超时为 10 分钟,扫描间隔为 2 分钟(在 Actor 的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?在 Actor 空闲的前 15 分钟之后会发生什么,因此 GC 和停用。那么它如何知道在 45 分钟后重新创建 Actor? And how does it know what actor ID to use to create the Actor with?以及它如何知道用于创建 Actor 的 Actor ID 是什么?

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://www.codit.eu/blog/2016/08/25/how-to-enable-automatic-scheduling-in-service-fabric-actors/

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

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).假设我们将提醒设置为在 1 小时后运行,但 Actor 的空闲超时为 10 分钟,扫描间隔为 2 分钟(在 Actor 的 ActorGarbageCollectionSettings 中设置)。

What happens after the first 15 minutes the Actor is idle so is GC'd and deactivated..在 Actor 空闲的前 15 分钟后会发生什么,因此 GC 和停用。

What happens is that the actor is automatically activated when needed by Azure Service Fabric and de reminder code is executed.发生的情况是,当 Azure Service Fabric 需要时,actor 会自动激活并执行提醒代码。 Using the events and virtual methods provided by the actor framework (OnActivateAsync / OnDeactivateAsync) this is easy to track.使用actor 框架(OnActivateAsync / OnDeactivateAsync)提供的事件和虚拟方法很容易跟踪。 In fact, I have a repo that shows exactly that using the EventSource based logging mechanism.事实上,我有一个repo ,它使用基于 EventSource 的日志记录机制准确地显示了这一点。

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 .至于 ASF 如何实际跟踪计时器和提醒,我们只能猜测,他们正在开源该项目,所以也许您已经可以查看源代码了

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编辑:我看到它在内部使用计时器,请参阅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 .有一个ActorManager可以跟踪ConcurrentDictionary特定ActorId的所有提醒。

Edit 2 : it is explicitly stated in the docs you added in your question:编辑 2 :它在您在问题中添加的文档中明确说明:

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.具体来说,由于 Actors 运行时会保留有关参与者提醒的信息,因此在参与者停用和故障转移会触发提醒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM