Konstantin Vyaznikov

Is there a way to force persistence of Workflow on Idle, without unloading of workflow from memory And is there a way to unload workflow without persistence

Basically what I want is not to unload workflow, but to persist it, when it is in idle state and I want to unload workflow, say when it is good time.

The reason behind is that I have to have persistence point, but I want to avoid reloading of workflow, when it is not required, thus to keep it in memory with potential unload.

Thanks,

Konstantin.



Re: Windows Workflow Foundation Is there a way to force persistence of Workflow on Idle?

Pradnya

Hi KV,

I forwarded your question about being to able persist a workflow without uploading to some folks here is the answer I recevied is that there two out of the box ways -

- The first is to have a TransactionScope or CompensatableTransactionScope

- Second is to create a custom activity with the PersistOnCloseAttribute. "

Some information about how to use PersistOnCloseAttribute

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=393967&SiteID=1

Thanks,

Pradnya






Re: Windows Workflow Foundation Is there a way to force persistence of Workflow on Idle?

KV

Thanks a lot for the reply.

This really works. Persistence point is created and everything is fine, except some cases.

Let me describe situation where it does not work. Persistence point is created, but execution does not resume after crash (runtime host is shutdown without calling Stop of runtime).

So, in order to illustrate the problem, I created the following workflow:

- Workflow consists of one parallel activity.

- Left branch contains only Delay activity, say for 10 seconds.

- Right branch contains activity with attribute [PersistOnClose]

Now 3 experiments with this workflow:

1. When this workflow runs from start to end, without interruption, I see that persistence point is created and after a delay of 10 sec, persistence point is removed on close of workflow. So far so good.

2. When this workflow is started and after I see that workflow idles on Delay activity, I shut down workflow in a regular way, by runtime.Stop(). New persistence point is created at this moment, overiding previous persistence point. After runtime.Start() workflow continues from latest persistence point and completes normally. So far so good. Behaviour as expected.

3. I start the workflow. After workflow creates persistence point and idles, I shutdown host, without calling runtime.Stop(). On this way I simulate computer crash. Peristence point is locked in persistence storage, so I unlock it manually, setting proper flags in DB record and restart runtime. Workflow is retrieved from persistence point, loaded, but it does not execute. It stays in idle state forever. I checked that queue is OK, there is an item in a queue, which should be delivered, but it is not, thus resulting in infinite idling, which is definitely wrong. Now a trick: If I Unload workflow at this moment, thus persistence point gets created, workflow unloads, then it loads immediately (delay is exausted) and workflow completes.

So, looks like the problem is either in creation of persistence point by using activity with [PersistOnClose] or TransactionalActivity (I tested both - result is the same). Or restoring from that persistence point is not that good, because workflow does not want to go any further. All necessary elements, like queue proper time delay are OK, which is proved by unloading of that workflow and recreation od persistence point.

I got exactly the same results, making my own parallel activity, consisting of [PersistOnClose] activity and my own delay activity. I did this all programmatically. Result is exactly the same. Workflow does not continue execution after loading from persistence point.

What I try to achieve is that after computer crash, on restart of host, workflow continue to execute, honoring delay. If say, delay was set for 1 day and computer was restored after a day, delay in execution was 0. And if computer was restored after half a day, delay was half a day.

Unfortunately I cannot garantee that in our conditions, runtime will be shut down normally.

If this question can be solved, that would be really great, because this ruins pretty big project. Any help in this would be kindly appreciated.

Thanks,

Konstantin.





Re: Windows Workflow Foundation Is there a way to force persistence of Workflow on Idle?


Re: Windows Workflow Foundation Is there a way to force persistence of Workflow on Idle?

KV

After hotfix installation, it works!

Thanks,

Konstantin.