【发布时间】:2016-05-25 18:46:18
【问题描述】:
我目前正在开发已开始使用hangfire 的EmailNotification 模块。唯一的问题是在尝试 10 次之后,如果在我的情况下 hangfire 未能(安排工作)电子邮件,我无法找到通过代码获取有关该更新的方法。
我知道,我可以通过如下配置hangfire来访问hangfire - 仪表板:
public void ConfigureHangfire(IAppBuilder app)
{
var container = AutofacConfig.RegisterBackgroundJobComponents();
var sqlOptions = new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = Config.CreateHangfireSchema
};
Hangfire.GlobalConfiguration.Configuration.UseSqlServerStorage("hangfire", sqlOptions);
Hangfire.GlobalConfiguration.Configuration.UseAutofacActivator(container);
var options = new BackgroundJobServerOptions() {Queues = new[] {"emails"}};
app.UseHangfireDashboard();
app.UseHangfireServer(options);
}
但问题是我无法找到以编程方式访问失败作业的方法。不知道有没有人遇到过这个问题,想详细了解一下。
【问题讨论】:
-
在这里尝试:docs.hangfire.io/en/latest/background-processing/… 查找“我们可以创建自定义异常处理程序”。也许这会有所帮助。我没有给出这个答案,因为我不确定。
-
基于自定义异常访问失败作业的逻辑,我不确定我是否喜欢这个想法。但是,我正在研究它 - 如果我发现一些方便的东西 - 会在这里更新 - 谢谢!
标签: c# asp.net rest asynchronous hangfire