I have an application which contains multiple state machine instances when running. I would like these to be implicitly persisted to a database in order that if the application is restarted, they can be re-loaded from the database and they will resume in the same state they finished in, along with any object properties which had been set while the instance was in memory.
Is such a thing possible?
I’ve been searching Google in vain, which means one of three things:
- This is impossible!
- I’m terrible at using Google
- A decent answer to this question will help out a lot of other folk
I hope the answer is 3! 🙂
Nhibernate is not particular useful for this because the physical persistence operation is a minor aspect of workflow persistence. The involved part is all the services that support unloading the reloading and activating workflows at the appropriate times etc. The inner workings of the runtime and services are also complicated by the fact that workflows span application boundaries that can last indefinitely. Various entities can be in various states at any given time. Since a call cannot be guaranteed to even have a client under these conditions, what the runtime actually does when you raise an event in a workflow for example is put a message in a queue rather than calling an actual function pointer. This is how you are able to “raise” an event in a workflow which is not running.
You can access these message queues and other low level details of the runtimes, but it is probably best to try to stay within the Microsoft framework and avoid rebuilding anything as much as possible. Si when you do things their way, which is much easier than tryiong to manage it yourself, Nhibernate becomes rather pointless because all it would do is persist a binary serialization stream.
Among the various extensions available, one is the ability to create custom persistence providers that can operate within the existing workflow framework. There is an Oracle provider already written. Cannot attest to it’s reliability, but you should at least be able to build on this.
http://wftools.codeplex.com/