WF4 workflow versioning using WorkflowServiceHost

我与影子孤独终老i 提交于 2019-12-03 08:53:10

The approach using the WorkflowServiceHost is not all that different form using a WorkflowApplication. The basics of keeping the various XAML(X) versions around still applies. So in the case of the WorkflowServiceHost you need to create multiple WorkflowServiceHost's each hosting a different version of your XAMLX. Each with a different endpoint. So basically an en endpoint both addresses a workflow service and its version.

So how to get messages from the client to the correct WorkflowServiceHost? Here the WCF Routing Service is your friend. Instead of having client communicate directly with your WorkflowServiceHost they use an intermediate WCF Routing Service. This in turn checks the messages and routes them to the WorkflowServiceHost hosting the appropriate XAMLX file. So how does it know. There are several ways to do so. For example doing a database lookup using a message correlation identifier with requests for new workflows always going to the last version. The easiest way is to have the workflow service return a version number as part of the initial request and make this a required part of each subsequent request. This way the WCF Routing Service can do all its works with just the message data send.

An example of this would be:

  1. The client send a message starting a new workflow using order Id 7 and receives version 3 back. The client application uses URL httl://localhost/MyWorkflow.xaml and the routing service forwards to httl://localhost/MyWorkflow.v3.xamlx which is the last version.
  2. Next message it sends to the workflow contains both orderid and version 3. The client application uses URL httl://localhost/MyWorkflow.xaml and the routing service forwards to httl://localhost/MyWorkflow.v3.xamlx which is the indicated version.
  3. The client app wants to send a message to an older workflow. It uses orderid 2 and version 1 (replied when this workflow was started). The client application uses URL httl://localhost/MyWorkflow.xaml and the routing service forwards to httl://localhost/MyWorkflow.v1.xamlx which is the version incicated.

Check these screencasts for more info about the WCF Routing Service.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!