Customizing the persisted data


I want to know if it is possible to customize/extend the data that gets persisted to storage when jobs get enqueued, and if it is possible to get access to the same persistence model before/during the deserialization process.

Basically, i need to enqueue some job for background processing, and i am using an IoC to activate the instance that owns the job function that hangfire will invoke; the catch is that while building the object graph, some data which are available within the request of the web app, will not be available when hangfire is ready to execute the job, so i need a place to store this, along with the info hang fire stores regarding the job.

An easy solution to this will be to alter my job function’s signature so all necessary data are passed into it, and can therefore be serialized by hang fire. However, i want to avoid this (if possible) because it will mean creating another abstraction layer for background job processes seating on top (or beneath?) my regular domain processes - an architectural decision i would rather not take on account of an introduced library (hangfire).

If hooking into the persistence process is not possible (at this time?), are there any other solutions that can help me out here?


So far what i have figured is that i can implement IClientFilter and IServerFilter on a custom filter, and configure it on the GlobalConfiguration. Now within the OnCreating method, i can use SetJobParameter to set any custom data i need persisted, then on the return trip, within the OnPerforming method, i can get out the serialized value and use it to prepare my object graph (hopefully) before the Dependency Resolver creates my instance.