6.5.1 共享连接的配置
下面的配置文件配置了SQL工作流服务和共享连接服务。因为我们把连接字符串定义在了CommonParameters节中,所以所有的服务都会使用这个连接字符串。
<?
xml version="1.0" encoding="utf-8"
?>
< configuration >
< configSections >
< section name ="WorkflowConfiguration"
type ="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</ configSections >
< WorkflowConfiguration >
< CommonParameters >
< add name ="ConnectionString" value ="Data Source=(local);Initial Catalog=WorkflowDB;Integrated Security=true" />
</ CommonParameters >
< Services >
< add type ="System.Workflow.Runtime.Tracking.SqlTrackingService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
< add type ="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
UnloadOnIdle ="true" />
< add type = "System.Workflow.Runtime.Hosting.SharedConnectionWorkflowCommitWorkBatchService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</ Services >
</ WorkflowConfiguration >
</ configuration >
我们不需要更改我们的应用程序,共享连接服务会在后台和其它Runtime服务一起协调。
< configuration >
< configSections >
< section name ="WorkflowConfiguration"
type ="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</ configSections >
< WorkflowConfiguration >
< CommonParameters >
< add name ="ConnectionString" value ="Data Source=(local);Initial Catalog=WorkflowDB;Integrated Security=true" />
</ CommonParameters >
< Services >
< add type ="System.Workflow.Runtime.Tracking.SqlTrackingService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
< add type ="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
UnloadOnIdle ="true" />
< add type = "System.Workflow.Runtime.Hosting.SharedConnectionWorkflowCommitWorkBatchService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</ Services >
</ WorkflowConfiguration >
</ configuration >
6.6 小结
本章回顾了Windows Workflow Runtime的一些功能。我们分析了如何通过订阅Runtime事件和配置跟踪信息来监视工作流Runtime,还分析了如何通过添加服务来定制Runtime。这些服务包括调度服务(用作管理线程)、持久化服务(用作管理状态)和跟踪服务(用作记录跟踪信息)。如果内置的服务并不能完全满足你的需求,我们可以自己编写服务来替换掉它们。这中架构给予了Windows Workflow Runtime很大的灵活性和扩展性。
译者注: 终于译完了第六章,这才发现MSDN已经更新了WF部分中文资源,许多词语也终于有了官方译法,比如之前我一直译作“持久化”的“Persistence”,官方译作了“持久性”,虽然我个人还是认为持久化更加形象,但日后的翻译还是以官方的为准,之前翻译好的部分,也就不再做更新了,相信也不会给大家的阅读造成太大的影响。 |