Timers in a Workflow hosted in ASP.Net

Hi

I'm building a web based workflow application and need to monitor the progress of the requests entered into the application and if a request hasn't been actioned after a period of time; send a notification email.

I've read several posts and bloggs that state the Persistence service is responsible for monitoring Workflows that are in an idle state and then responding to delays within the Workflow that expire. I realise that because of the nature of ASP.Net the runtime is unloaded after each call, so I'm confused as to how, if the service isn't instantiated, it can perform this task.

Thanks for any help.

DB

[651 byte] By [Delboy] at [2007-12-22]
# 1
As long as you have the JuneCTP installed (WF RC2) Delay activities inside of workflows will behave properly in ASP.NET with the ManualSchedulerService (which was a problem before RC2).
JonFlanders at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2
John is correct in that the June CTP will solve the problems with use of ManualSchedulerService (which should be used with ASP.NET), though don't you need to set a flag on it or is it defaulted to true?

My concern is in your statement "I realise that because of the nature of ASP.Net the runtime is unloaded after each call", which I felt was more important to correct, since you thought that to be the reason the timers wouldn't kick off. The WorkflowRuntime object is sitting in Application level session, not within the scope of the Page object, and so does not get unloaded after each call.

RichardGavel at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3

So if no one is using the application (over night for example) and a delay expires the next activity will execute?

DB

Delboy at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4

Yes, that is correct. Execution of the instance will continue when the timer fires and unblocks the instance.

Thanks,

Joel West

MS SDE in WF runtime and hosting

This posting is provided "AS IS" with no warranties, and confers no rights

JoelWest at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5

Joel,

What about "Shutdown worker processes after being idle ..." or "Recycle worker processes" on the IIS Application Pools? During this action, the WorkerRuntime core (all services) is shutdown also and the Application will wait for first Request to start up.

How is this situation handle? Is there a special Windows NT Service for hosting the timers?

Thanks

Roman

RomanKiss at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6

After a website recycle timers will not be processed until the next workflow webservice request. This will start up the runtime again and it will start processing timers.

Thanks,

Joel West

MS SDE in WF runtime and hosting

This posting is provided "AS IS" with no warranties, and confers no rights

JoelWest at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 7
So if that is the case, would I be better off having a Windows Service that would be constantly running the workflow? Then if the web site was down the timers wouldn't get missed. Or should I use some custom Stored Procs instead?
Delboy at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 8

Hi All

I'm still having an issue with Delays in ASP.Net. I moved the Runtime instantiation into the Global.asax and using SQL Profiler I can see that 'RetrieveExpiredTimerIds' stored procedure runs every two minutes (if I run the SP manually it returns my workflows with timers that have expired) but still my workflows do not progress past the delays. The only way I can get it to work is if I call the ManualWorkflowScheduler service passing in the workflow GUID. I've got the July CTP, and I've recreated the DB with the latest scripts. Am I just being stupid here, or should this work?

DB

Delboy at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 9

DB,

Make sure you set the UseActiveTimers to true on the ManualWorkflowScheduler service. You can add this as an attribute in the web.config if you are adding the service that way, or you can use one of the constructors (the one that takes a bool for active timers or the name value collection that can include the UseActiveTimers item).

Matt

MattMilner-Pluralsight at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 10

Matt,

Thanks, that's fixed it. You the man. While I have your attention, do you know if there is anyway to make sure the web app is always running. I've set the App Pool to never Recycle the worker process but if the server is rebooted I need to ensure that the application starts again. Thanks again.

DB

Delboy at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 11

There are products out that there will ping your site for you on a regular basis to keep them alive.

You could also write a simple service that does nothing but ping your site on a periodic basis (every 5 minutes or so) to make sure it stays alive.

Finally, you might look at the MOM packs for web application and web services. They might allow you to easily see when your app is recycled and then use a script to ping it to bring it back into memory.

Keep in mind that recycling has some benefits. Rather than trying to keep your app in memory all the time, I'd try to hit it on a recycle so that you get back a new fresh instance rather then waiting for a user to interact with the site.

Matt

MattMilner-Pluralsight at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 12

Thanks Matt

I'm going to write a service based around this snippet and a timer (without the Messagebox):

Dim siteUri As New Uri("http://localhost/WFWebSite/Default.aspx")

Dim wr As WebRequest = WebRequest.Create(siteUri)
wr.Credentials = CredentialCache.DefaultCredentials
Dim response As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
MessageBox.Show(response.StatusDescription)

Thanks everyone who contributed.

DB

Delboy at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 13

Hi Matt,

have you already any experiences with the MOM 2005 pack for IIS?

Thank you

simon at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 14

No, I have not had much experience with that MOM pack. I only suggested it as a possible option for a health monitoring tool that could ping the service/web app as someone might have MOM in their environment and be able to grab the low hanging fruit.

Matt

MattMilner-Pluralsight at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified