SharePoint Workflow architecture (1) Integration of SharePoint and Workflow Runtime, sharepointworkflow
According to Andy Li, I have read the best and most thorough article on SharePoint Workflow architecture. After reading his article, I learned about the working mechanism of SharePoint Workflow and how to locate the problem. Therefore, we hope to help Workflow developers.
This blog was contributed by Andy Li. He is an engineer in the SharePoint support team who handles problems. Original address. This Workflow series is contributed to the community to help you better understand the internal mechanism of Workflow runtime and how to interact with SharePoint.
This article is translated by SPFarmer.
Combination of SharePoint and Workflow Runtime
The following chart describes the components of SharePoint Workflow. First, let me give a brief explanation of the data stream. Then, in the following chapters, I will introduce each part in detail.
First, let's look at how you start a workflow.
This section describes the modules pointed to by the blue arrows on the left of the above chart.
1. on the workflow page of the List or Library, click the workflow associated with the list or library. Then you are redirected to the workflow initial Form (Initiation Form, if your workflow has an initial Form ).
2. After the initial Form is submitted (Initiation Form), the message is sentSPWorkflowManager.SPWorkflowManagerIt is the only object that can be used to start a workflow example in the pivopointobject Model.
3.SPWorkflowManagerThen notify SharePoint workflow runtimeobject (SPWinOeHostService) You need to start a workflow instance.
4.SPWinOeHostServiceThe function is to notify Windows Workflow Runtime to start a workflow instance.System. Workflow. WorkflowRuntime. CreateWorkflow ()And then callSystem. Workflow. WorkflowInstance. Start ().
Another common scenario is to submit a workflow task..
It is difficult for many people to understand how the data of a task is transmitted to a workflow instance. This is actually the most complicated part of SharePointWorkflow, because it involves many modules of Workflowruntime and SharePoint. I will first explain the data stream in a summary, and then explain the details in the following blogs.
1. This process starts when you open a form of workflow task.
2. If you have a custom task form, you usually callSPWorkflowTask. AlterTask ()To submit the changes to this task. This API is called againSPListItem. Update ()If you do not have a custom task form, OOBSharePoint tasks do the same thing in essence.
3. The mechanism for transmitting data from a task to worokflow is implemented through eventreceivers. You may have thought of it. Yes, this is how the task data is transmitted to workflow. I will explain how event receivers is registered on tasks. now you need to know that each workflowtask has an eventaggreger hook on it. The purpose is to pass the task changes to the corresponding workflow instance.
4. Event aggreger callSPWorkflowManager(Yes, it is the only private method that can call the workflowruntime object)SPWorkflowManager. RunWorkflow (). That is, as a developer, you can only callSPWorkflowTask. AlterTask ()OrSPListItem. Update ()To start this action.
Note: SharePoint 2010 introduces a new concept calledPluggableService to implementWorkflow can interact with any external service, such as custom WCFservice. This is impossible in SharePoint2007. In SharePoint2007, workflow can only communicate with workflow through SharePointTask. in the chart,SPWorkflowExternalDataExchangeService It is used to pass custom events to workflow. In essence, this is the same as passing task changes to workflow, so here we use the built-in task to explain other things.
5. ThenSPWorkflowManagerPass the data to SharePointworkflow runtime, and then find out who should pass the data. For example, if this is a task or a normal item based on the data type, the corresponding dataexchange service will continue to transmit data.
6. All data exchange services, even if they are based on Workflow Communication Services. In SharePoint,Microsoft. SharePoint. Workflow. ITaskServiceIs an interface for data exchange between workflow and SharePoint. We will discuss more later.