StateMachine Webservice Runtime

Hi,

Firstly, I'm quite new to WF... 3 weeks using it. Steep learning curve....

I've searched all over but cant seem to find a solution.

The problem i'm having is my StateMachine is not firing off the Delay event correctly.

I created a StateMachine workflow and published it as a webservice. This works great with webservice calls etc and changes through all the states just fine. The workflow models a basic bug tracking service.

When the state changes to Open, there is a delay event set to fire up after 5 minutes. The event fires off an e-mail and changes the state to escalated. This works fine, if you keep calling functions exposed by the web service e.g. CheckCurrentState().

The StateMachine also does persistence correctly without any hassles.

The delay event doesnt get fired off if you set the state to open and then leave your browser idle.

I've tried with the persistence service set to unloadonidle set to true and false, doesnt make a different.

I gather the runtime hosting the workflow is being created when the webservice is called and then disposed of when finished... is there any way to keep this runtime alive

The webservice is running in under IIS on my local box (Win XP)

Any help greatly appreciated!!



Answer this question

StateMachine Webservice Runtime

  • micha12

    Great. Thanks a mil. Works like a dream. :)
  • Joannes Vermorel - MSP

    When a workflow is published as a webservice, it is configured to use the ManualWorkflowSchedulerService. When the ManualWorkflowSchedulerServiceis used, it means that the host must explicitly donate the thread on which the workflow is to run by calling RunWorkflow. This is done automatically for you, but when a delay is executed, control goes back to the host. When the delay expires, there is no-one to call RunWorkflow on the idle workflow and so it does not resume. However, there is a setting for ManualSchedulerService called ActiveTimers, that when set to true, weill automatically resume execution of the workflow. In normal code you would specify this in the constructor, like this:

    public ManualWorkflowSchedulerService (
    	bool useActiveTimers
    )
    useActiveTimers
    Boolean that determines how delay activities are handled. If true, the scheduler service automatically resumes workflows after delay activities expire (by using an in-memory timer). If false, the host must manually resume the workflow after the delay activities expire.
    When publishing a workflow as a webservice, this is done in the web.config file for the webservice. The default config looks like this:
    <add type="System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
     
    Add useActimers="true" to the end like this:
    <add type="System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" useActiveTimers="true"/>
    and you should be all set
    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
     

  • StateMachine Webservice Runtime