I used the repetitive work of Hangfire to execute my long process with a cron expression every minute (so basically it starts every minute to retrieve the data in db and do some processing), and I used the repetition of the Hangfire implementation of 3 when it fails .
Questions:
- How does retry work inside Hangfire? Is repetitive work being performed every minute, and is retrying in parallel?
- and how do I know if repetition 3 is already completed or has already been achieved (in code)?
The reason I want to know that the retry has already been reached, because I need to do something with my data in my database, processed by the repetitive Hangfire operation.
Note. Viewing the dashboard to search for a replay is not my option here, but through the code. Is it possible?
Implementation:
public class HangfireImpl
{
public static void ConfigureHangfire(IAppBuilder app, string dashBoardName, string connectionString)
{
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 3 });
GlobalConfiguration.Configuration
.UseSqlServerStorage(connectionString)
.UseDashboardMetric(SqlServerStorage.ActiveConnections)
.UseDashboardMetric(SqlServerStorage.TotalConnections)
.UseDashboardMetric(DashboardMetrics.FailedCount);
app.UseHangfireDashboard(string.Format(@"/{0}", dashBoardName));
app.UseHangfireServer();
}
public static void InitializeJobs()
{
RecurringJob.AddOrUpdate<Worker>(service => service.Execute(), Cron.Minutely);
}
}
source
share