hangfire

how to run yearly recurring job using cron

我只是一个虾纸丫 提交于 2019-12-25 16:49:43
问题 Hangfire is using ncrontab to run recurring job. Does this below contab run every weekly Monday at 12 am for only 2017 ? 0 0 * * 1 How can I make sure it runs only for 2017 or every year? 回答1: Hangfire uses NCrontab library. As you could see, this lib provides a way to rapidly test its own functionality. Just open C# Interactive window in Visual Studio and paste a code like below: #r "C:\Users\YOUR_USER\.nuget\packages\ncrontab\3.3.0\lib\netstandard1.0\NCrontab.dll" using NCrontab; var s =

“Thread was being aborted” exception raised in excuting Hangfire job

有些话、适合烂在心里 提交于 2019-12-25 00:17:22
问题 I have a Hangfire (with SqlServer for persistence) job which query some data from database. Then generate an Excel with NPOI with these data, and sent it via Email to users. The data is not so large, only like 1,000 rows. So the job executes in seconds. However, I get "Thread was being aborted" exception when generating Excel or sending mail. I guess there is something like Timeout, which kills the thread. Does anyone have the same issue? Any solutions? 回答1: Alright. Actually I made a stupid

JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API

别等时光非礼了梦想. 提交于 2019-12-24 20:09:48
问题 I am using hangfire in mvc application. I am sending reminder to user for his/her appointment. I have installed hangfire in my app. I have configured hangfire in startup.cs class. But when i run the app, it produce the below error, JobStorage. Current property value has not been initialized. You must set it before using Hangfire Client or Server API. using Hangfire; using Hangfire.SqlServer; using Microsoft.Owin; using Owin; using System; using System.Collections.Generic; using System.Linq;

Queuing BankgroundJob with Hangfire within an async action in ASP.NET MVC freeze the application

ⅰ亾dé卋堺 提交于 2019-12-24 03:30:47
问题 I have this action on one of my controllers which is called by another method which has been called also by another action. All works fine, unless I try to en-queue with Hangfire some jobs: _bankClient.FetchAndEnsureTransactionsAsync and _bankClient.RefreshItemAsync . This is causing the application to freeze (the client, browser, stops while the server is still running). I suppose is some weird deadlock , but nothing I've tried seems to make it work! Would someone know how to solve this

Queuing BankgroundJob with Hangfire within an async action in ASP.NET MVC freeze the application

雨燕双飞 提交于 2019-12-24 03:30:03
问题 I have this action on one of my controllers which is called by another method which has been called also by another action. All works fine, unless I try to en-queue with Hangfire some jobs: _bankClient.FetchAndEnsureTransactionsAsync and _bankClient.RefreshItemAsync . This is causing the application to freeze (the client, browser, stops while the server is still running). I suppose is some weird deadlock , but nothing I've tried seems to make it work! Would someone know how to solve this

Set Hangfire succeeded job expiry attribute not working

穿精又带淫゛_ 提交于 2019-12-23 10:26:40
问题 I am using Hangfire to do jobs, and I'd like to change the behaviour that succeeded jobs are deleted from the database after a day - I'd like them to be stored for a year. Following the instructions in this thread, which is the same as in this SO question, I have created a class: public class OneYearExpirationTimeAttribute : JobFilterAttribute, IApplyStateFilter { public void OnStateUnapplied(ApplyStateContext context, IWriteOnlyTransaction transaction) { context.JobExpirationTimeout =

Hanfire not logging custom exception with metadata

元气小坏坏 提交于 2019-12-23 02:42:20
问题 I have asp.net core 2.1 application along with HangFire 1.6.17 . HangFire is configured to execute a background job at certain interval. The background job calls external API using HttpClient. If the http call fails, then the method throws custom exception with metadata. Idea is hangfire will log the exception with metadata. I followed best-practices-for-exceptions to create exception public class MyHttpRequestException : Exception { public string Content { get; private set; } public string

Scheduled tasks limitations (or how tasks persistence is implemented)?

孤街醉人 提交于 2019-12-22 04:18:14
问题 I've started to read Hangfire documentation, and found nothing about task limitations. As declared, tasks (or jobs) are stored somewhere. Since they are just delegates, the only thing could be stored, as far as I understand, is a delegate "body" (IL?). But there could be closures, that provides some context for the task, e.g., some external services, that can require to load extra assemblies to run their code, etc. How Hangfire deals with this? Can task contain any instructions in its body,

How can I pass a SignalR hub context to a Hangfire job on ASP .NET Core 2.1?

ぐ巨炮叔叔 提交于 2019-12-21 05:22:32
问题 How can I pass a SignalR hub context to a Hangfire job on ASP .NET Core 2.1? It seems that since passing arguments to Hangfire is done via serialization/deserialization, it seems that Hangfire has hard-time reconstructing the SignalR hub context. I schedule the job (in my controller) using : BackgroundJob.Schedule(() => _hubContext.Clients.All.SendAsync( "MyMessage", "MyMessageContent", System.Threading.CancellationToken.None), TimeSpan.FromMinutes(2)); Then after 2 minutes, when the job

Execute a recurring job in Hangfire every 8 days

蓝咒 提交于 2019-12-21 03:47:18
问题 Is it possible to create a recurring job in Hangfire that executes after a given number of days, say 8. The nearest I found was to execute a job once in a week - RecurringJob.AddOrUpdate("MyJob",() => ScheduledJob(), Cron.Weekly()); Understanding that Hangfire also accepts standard CronExpression , I've tried exploring cron expression for this frequency but couldn't found one for it- https://en.wikipedia.org/wiki/Cron One ugly solution could be to create 3 or 4 jobs that executes once in