Currently I have Hangfire running as a service and jobs being scheduled by an MVC application.
I want to transparently pass the id of the logged user as a parameter to the job when it’s scheduled (Hangfire doesn’t have access to that property).
Is it possible to somehow pass data implicitly to the job server? Is there any easy way to accomplish this (e.g. without modifying Hangfire database)?
Not exactly what you’re after but…
Lets say you have a method called “LoggData” with one argument “data”
Instead of calling HF to schedule this method, create a NEW method called “stubLoggData”, add in a argument “userID” (or whatever). Then re-work your scheduler methods to call the new method, inserting the data you need. Inside this new “stub” methob, call the original method required while processing the other information you need.
I do this alot with web services where renaming the methods is out of the question.
Hope this helps
Hi, LeadMagnet.
I guess I’ll have to go for that then, as there doesn’t seem to be a way through Hangfire.
Thanks a lot for your help.