简体   繁体   中英

Windows Workflow Delay Activity Behavior

I feel my question is somewhat straight forward, but I've added some details of my problem in the "Background Info" section in case it is too vague.

Question

How does the WorkflowServiceHost determine that a persisted activity, that is Idle due to Delay, has reached the Delay timeout? Does it load it into memory and check every so often, or is there something else happening here?

Background Info

So, I'm a bit new to workflow and I'm trying to determine the feasibility of using it for a business process that would use a 3 month delay. Basically, the business process is to allow a customer a 3 month trial of upgraded service. To accomplish this, I'm thinking of implementing a Pick activity that splits between a WCF Receive ("Cancel upgrade receive") and a 3 month Delay activity. If the delay expires, they are upgraded permanently and billing is updated. Alternatively, if the cancel is initialized then, well... yeah, you get the idea :)

So.... my concern is in regards to how Delay is implemented when using SQL workflow persistence. I don't want to end up w/ 500 activities in the persistence store that have to be loaded every 10 minutes for 3 months in order to check if the Delay activity expired.

According to https://msdn.microsoft.com/en-us/library/ee829473(v=vs.110).aspx , the way this works is that:

The SQL Workflow Instance Store runs an internal task that periodically wakes up and detects runnable or activatable workflow instances in the persistence database

An activatable workflow is a workflow that meets either of the following criteria:

  • The instance is unlocked and has a pending timer that has expired.
  • The instance has an expired lock on it.
  • The instance is unlocked and its status is Executing.

So the suggestion of the OP (" Does it load it into memory and check every so often") is correct.

I have not confirmed this behavior myself, but stumbled upon this thread as I was looking for an answer to the exact same question, then found the relevant MSDN article, which I wanted to share with you.

Hope this helps.

I was looking at this same problem with a much smaller window of time. I still would love to hear if/how you resolved this using workflow?

I am using WF4 and a pick as you stated above and then my solution is to try and use appfabric for reinitialising the workflows based on the delayed timer. This is based on what I read here: Hosting workflow services with durable timers / delays and this here: Activation of workflow service instances

I have tested that the pick works perfectly with a delay on one side, but now I have to test appfabric out.

Perhaps, I will come back with an update here on how it works out. Or you can give me some insight?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM