使用 Hangfire 监控获取所有成功的作业 API
Get all Succeeded Jobs with Hangfire Monitoring API
我在 Hangfire 中使用 JobStorage.Current.GetMonitoringApi()
来计算所有成功任务的数量。为此,我使用了以下函数:
var api = JobStorage.Current.GetMonitoringApi();
var succeededJobs = api.SucceededJobs(0, int.MaxValue);
但是,这似乎只是 return 最近几天的成功作业。在我的例子中,它 returns 95
但如果你看看我的仪表板,我会看到更多。
有没有办法通过MonitoringApi拉取所有历史作业数据?
解决方案是为每个作业设置 JobExpirationTimeout
属性 以防止它被过早地从存储中移除。
这可以通过 IApplyStateFilter
来完成。
查看:
https://discuss.hangfire.io/t/how-to-configure-the-retention-time-of-job/34
我在 Hangfire 中使用 JobStorage.Current.GetMonitoringApi()
来计算所有成功任务的数量。为此,我使用了以下函数:
var api = JobStorage.Current.GetMonitoringApi();
var succeededJobs = api.SucceededJobs(0, int.MaxValue);
但是,这似乎只是 return 最近几天的成功作业。在我的例子中,它 returns 95
但如果你看看我的仪表板,我会看到更多。
有没有办法通过MonitoringApi拉取所有历史作业数据?
解决方案是为每个作业设置 JobExpirationTimeout
属性 以防止它被过早地从存储中移除。
这可以通过 IApplyStateFilter
来完成。
查看: https://discuss.hangfire.io/t/how-to-configure-the-retention-time-of-job/34