hangfire extension
1 services.AddHangfire(config => 2 { 3 config.UseRedisStorage( 4 Configuration["RedisConnectionString"], 5 new RedisStorageOptions 6 { 7 Db = 7, 8 Prefix = "abc-sys" 9 }); 10 });
app.UseHangfireServer(); app.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new HangfireAuthorizationFilter() }, IgnoreAntiforgeryToken = true, AppPath = "/swagger/index.html", DashboardTitle = "Abc Sys Hangfire Dashboard" }); app.AddOrUpdateJobs();
/// <summary> /// HangfireAuthorizationFilter /// </summary> public class HangfireAuthorizationFilter : IDashboardAuthorizationFilter { /// <summary> /// no authorize /// </summary> /// <param name="context"></param> /// <returns></returns> public bool Authorize(DashboardContext context) { return true; } }
/// <summary> /// TestJob /// </summary> [SimpleJob(IsOpen = true, JobId = "TestJob", CronExpression = "0 0 8 * * ?")] public class TestJob : BaseRecurringJob { /// <summary> /// execute job /// </summary> /// <returns></returns> public override async Task Execute() { //todo job } }
github url:https://github.com/cailin0630/AspNetCore.Hangfire.Extension
在ASP .NET CORE中使用 hangfire 分布式任务框架
原文:https://www.cnblogs.com/jiangyihz/p/12878020.html