[英]Long-running service fabric actor reminder callback
I have an SF actor service that works roughly like this:我有一个 SF 演员服务,它的工作原理大致如下:
RunAsync
the service creates predefined set of actors and activates all of them by calling an empty StartAsync
method (defined on the IActor
-derived custom interface).当在启动RunAsync
的服务创建的预定义组的演员,并通过调用一个空激活所有这些StartAsync
方法(所定义的IActor
衍生自定义接口)。OnActivateAsync
in which it registers a reminder with dueTime
and period
both set to 10 seconds.每个 actor 都会覆盖OnActivateAsync
,其中它注册了一个提醒, dueTime
和period
都设置为 10 秒。IRemindable.ReceiveReminderAsync
implementation.演员在IRemindable.ReceiveReminderAsync
实现中完成所有工作。 The work is usually quick (~100 milliseconds), but sometimes it can last for several minutes (I know that this is bad design, please do not comment on that :-)).工作通常很快(~100 毫秒),但有时可能会持续几分钟(我知道这是糟糕的设计,请不要对此发表评论:-))。My question is: What happens when a reminder is due, but the actor still executes the previous callback code?我的问题是:当一个提醒到期,但actor仍然执行之前的回调代码时会发生什么?
According to the documentation , the callbacks are queued, but I also wonder if the queue is limited somehow and what happens when the limit is reached? 根据文档,回调已排队,但我也想知道队列是否以某种方式受到限制以及达到限制时会发生什么?
Thanks for your feedback!感谢您的反馈意见!
Palo帕洛
I have poked around the SF Actors framework source code ( ActorReminder.cs
) and found out the answers (thanks to the beauty of open source :-):我浏览了 SF Actors 框架源代码 ( ActorReminder.cs
) 并找到了答案(感谢开源的美妙之处:-):
What happens when a reminder is due, but the actor still executes the previous callback code?当一个提醒到期,但actor仍然执行之前的回调代码时会发生什么?
Actually, this never happens.事实上,这从来没有发生过。 The reason is that the ActorReminder
class uses the System.Threading.Timer
class for triggering reminders by means of the Change
method overload that uses the Timeout.InfiniteTimeSpan
for its period
argument.原因是ActorReminder
类使用System.Threading.Timer
类通过使用Timeout.InfiniteTimeSpan
作为period
参数的Change
方法重载来触发提醒。 This means that your reminder callback can execute for hours and SF will happily wait for it to complete without complaining.这意味着您的提醒回调可以执行数小时,SF 会很乐意等待它完成而不会抱怨。 After the reminder callback completes, ActorReminder
will „rearm“ the timer for the due time you specified when registering the reminder.提醒回调完成后, ActorReminder
将在您注册提醒时指定的到期时间“重新设置”计时器。
This also means that there are no such things as queued reminder callbacks, which obviously answers my second question :-).这也意味着没有排队提醒回调之类的东西,这显然回答了我的第二个问题:-)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.