这是我的akka actor代码,无论dotnet c#中的异步任务如何,都可以独立运行它
SchedulerAktor._actorSystem.Scheduler.ScheduleTellRepeatedly(TimeSpan.FromMinutes(interval),
TimeSpan.FromMinutes(interval),
SchedulerAktor._actorRef,
new Messages(),
ActorRefs.NoSender);
这也是对象的侦听器
protected override void OnReceive(object message)
{
var settings = new TaskSchedulerSettings(_mongoSetting, _appDbSQLctx);
switch (message)
{
case Messages messages:
log.Info("information needed here please try");
settings.FindAutoActionToExecute(DateTime.UtcNow).Wait();
break;
}
}
这是我的演员实现
_actorSystem = ActorSystem.Create("SchedulerAutoAction");
_actorRef = _actorSystem.ActorOf<TaskSchedulerAktor>("TaskSchedulerAutoAction");
我的大部分任务都在c#中异步运行,而我的大多数方法都避免了任何操作中断。
基于我的Akka登录dotnet 它显示
INFO][6/26/2019 4:09:33 AM][Thread 0009][[akka://SchedulerAutoAction/user/TaskSchedulerAutoAction#554886675]] information needed here please try
mongodb closed!
[INFO][6/26/2019 4:10:33 AM][Thread 0009][[akka://SchedulerAutoAction/user/TaskSchedulerAutoAction#554886675]] information needed here please try
mongodb closed!
[INFO][6/26/2019 4:11:33 AM][Thread 0028][[akka://SchedulerAutoAction/user/TaskSchedulerAutoAction#554886675]] information needed here please try
mongodb closed!
[INFO][6/26/2019 4:12:34 AM][Thread 0028][[akka://SchedulerAutoAction/user/TaskSchedulerAutoAction#554886675]] information needed here please try
mongodb closed!
[INFO][6/26/2019 4:13:34 AM][Thread 0009][[akka://SchedulerAutoAction/user/TaskSchedulerAutoAction#554886675]] information needed here please try
mongodb closed!
[INFO][6/26/2019 4:14:34 AM][Thread 0026][[akka://SchedulerAutoAction/user/TaskSchedulerAutoAction#554886675]] information needed here please try
我在Akka中尝试了操作调度程序,但根据他们的文档,它不希望它正确运行,但是存在差异 在调度程序上
The default implementation of Scheduler used by Akka is based on job buckets which are emptied according to a fixed schedule. It does not execute tasks at the exact time, but on every tick, it will run everything that is (over)due. The accuracy of the default Scheduler can be modified by the akka.scheduler.tick-duration configuration property.
https://doc.akka.io/docs/akka/current/scheduler.html
我认为它应该运行不一致。
我只想每1分钟运行akka,并且不应该像我那样影响异步操作。问题还是在我的方法执行之后或花了很多时间。
任何人都必须建议或建议如何正确执行此操作吗?