基于项目documentation ,在java版本中存在一些基于cron的调度。但我在 .net 实现中没有找到任何类似的东西。
我的任务是每天使用长时间运行的作业更新我的缓存。在这种情况下(.net 版本没有内置调度功能)我考虑创建应用程序,它将在客户端模式下运行 ignite 并使用数据更新缓存。并使用 Windows 任务计划程序运行此应用程序。
有更好的解决方案吗?或者也许是一个很好的例子?
收到答复后实现的解决方案:
二手FluentScheduler用于定期安排作业。不幸的是HangFire我本来打算用的,没成功。如果包含当前执行调度程序的节点由于某种原因发生故障或离线,则服务会在其余节点之一上启动,并且不会丢失任何调度作业。
调度程序作业代码
public class CacheUpdateRegistry : Registry
{
private readonly IIgnite _ignite;
public CacheUpdateRegistry(IIgnite ignite)
{
_ignite = ignite;
// output to console current node id as example each 2 seconds
Schedule(() => Console.WriteLine("Recurring on node: + " + _ignite.GetCluster().GetLocalNode().Id)).ToRunNow().AndEvery(2).Seconds();
}
}
服务代码:
public class CacheUpdateSchedulerService : IService
{
[InstanceResource]
private readonly IIgnite _ignite;
public void Init(IServiceContext context)
{
Console.WriteLine("CacheUpdateSchedulerService initialized");
obManager.Initialize(new CacheUpdateRegistry(_ignite));
}
// other code removed for brevity
}
点燃节点代码:
var services = _ignite.GetServices();
services.DeployClusterSingleton("cacheUpdateScheduler", new CacheUpdateSchedulerService());
最佳答案
Java 中的 Ignite Scheduler API 非常基础且仅限本地。实际上,它与 Ignite 几乎没有任何关系。
这就是为什么我们决定在 .NET 端省略此 API:使用 Timer 可以实现同样的效果。类。
关于.net - apache ignite .net 计划任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46919766/