HttpWorkflowResource is an internal part of the hosting infrastructure for HTTP Workflow Services. It is actually a WCF WebApi Service which is configured to receive all requests for a given BaseAddress. It is created by the HttpWorkflowServiceHost.GetInstance
which invokes a ctor providing the class with access to the request message. It maintains a cache of WorkflowApplication instances which may be resumed later depending upon the idle timeout settings.
[WebInvoke(UriTemplate = "*", Method = "*")]
public HttpResponseMessage InvokeWorkflow()
When a message is received
- It locates the HttpReceive activity with the matching UriTemplate
- It then attempts to correlate the request to a matching workflow instance. If no correlated instance is found an CanCreateInstance == true it creates and caches a new workflow instance
- It locks the instance to prevent concurrent access and runs the workflow until it becomes idle with the bookmark for the UriTemplate
- Resume the bookmark which will invoke the HttpReceive activity and wait for the HttpReceive to set the response
- Return the response created by the HttpReceive activity. The workflow may continue processing after the response is sent.
- How long to cache idle WorkflowApplication instances
- What happens if a workflow goes into an endless loop after the response is sent? Could/Should the host do something about this?