I started working with Hangfire last week and so far I like what it has to offer. However, there is one area where I keep running into problems. Job scope within filters. I’m assumed Job Scopes follow the same pattern as WebAPI/OwinContexts however that does not appear to be the case.
Anytime I reference JobActivatorScope.Current within a filter, be it a singleton or a transient, Current is always null. I pulled the source down and, if I’m following the code path correct, A scope does not begin until after a the Filters are resolved, but before the Job executes.
Our system leverages StructureMap and nested containers quite a bit and we were hoping to continue that pattern with Hangfire since there is support of nested scopes.
Two examples of how we are using nest containers:
- unit of work pattern and database transactions
- pushing the current user into the scope.
Is it possible to access/share the active job scope that will be used to resolve and exeucte the job? Are there any code examples covering this behavior?