WF4 workflow versioning using WorkflowServiceHost

怎甘沉沦 提交于 2019-12-04 14:07:04

问题


Related to this question.

I understand how to implement versioning of workflows using WorkflowApplication. If you keep the original XAML definition for older versions of your workflow around, you can load them using the right WorkflowApplication constructor.

How could you ensure that WorkflowServiceHost uses the correct workflow definition when you want to host your workflows in IIS?

There is a WorkflowServiceHost constructor that you can use to load a workflow definition, but when you are hosting inside IIS through a XAMLX file, you do not call WorkflowServiceHost yourself, this is handled somehow by IIS. So how do I ensure that the correct workflow definition is loaded for the right version of my workflow?


回答1:


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.



来源:https://stackoverflow.com/questions/2433670/wf4-workflow-versioning-using-workflowservicehost

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