views:

739

answers:

2

Hi

I have state machine workflow using in web applicaton. I persisted my workflow in sql server. When i invoke second time in my workflow using instanceid it's invoked. but after the process it will delete my instance from InstanceState table. even i am not assign setstate = completed state.

Regards Dhanraj.S

A: 

Make sure your workflow is actually waiting for actions; the simplest would be to use 2 delay activities, with different timeouts, because they don't require external events to be triggered.

Workflows are removed from the InstanceState table as soon as they complete (or error)

Sander Rijken
A: 

Hi Dhanraj,

Actually, Workflows are removed from the InstanceState table whenever an instance is "re-hydraded" and loaded back into memory, which occurs in response to an external trigger (inbound message, DelayActivity timer expiration, etc.) and will not be put back into the InstanceState table unless you have another persistence point in your workflow, or if you explicitly Persist the instance in code through the runtime. InstanceState is not a repository for "unfinished" workflows, but rather, for unfinished workflows that have been explicitly persisted or are waiting for some stimulus to continue work.

If you're concerned because you want better information on the state of the workflow, I would use the WorkflowTracking db, as that db keeps good record of the state and lifetime of your Workflows.

If, however, you're concerned because your workflow isn't done and should persist, you can check a couple of things. First, do you have UnloadOnIdle = true in your Runtime config? If that's set to false, only explicit calls to persist the WF instance will do so. On the other hand, if your config is properly structured and you're still not seeing persistance, that likely means that the instance is still in memory beause it is still doing something.

I hope this helps. Those are my thoughts without seeing a visual of the WF and where your problem is occuring. Could you attempt to post a basic flow of your WF and where the issue is occuring?

Not quite. Workflows are NOT removed from the InstanceState table when they are rehydrated. If they where removed and your program would crash before a next persist the workflow would be gone for ever, not a good thing.
Maurice
Thanks Maurice, that was my incorrect recollection of the Persistence service. It does, in fact, leave re-hydrated workflows in the table until completion or fault. Thanks for keeping me honest. :)