Search code examples
c#.netdependency-injection.net-corehangfire

How to add additional job params that are substituted to CoreBackgroundJobPerformer in Hangfire.io


In the excellent hangfire.io library jobs can be executed with special params that are substituted at job execution such as IJobCancellationToken which allows you to cancel a job. Similarly PerformContext can be added as a param at runtime. This functionality is implemented in the CoreBackgroundJobPerformer

How can I add my own customised substitutions so I can change the substitution behaviour to substitute my own params at job execution in addition to the built in param substitutions?

AFAIK I would need to implement a custom IBackgroundJobPerformer that would be created by a custom BackgroundJobServer. But is there an easier way?


Solution

  • It seems there is not an easy way to do this and would probably require some changes in hangfire or running a forked version. Further discussion of how this may be implemented is at https://github.com/HangfireIO/Hangfire/issues/1221