惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Register - Security
The Register - Security
The Cloudflare Blog
Last Week in AI
Last Week in AI
月光博客
月光博客
Security Latest
Security Latest
Project Zero
Project Zero
博客园 - 司徒正美
AWS News Blog
AWS News Blog
雷峰网
雷峰网
博客园 - 聂微东
C
Cybersecurity and Infrastructure Security Agency CISA
P
Palo Alto Networks Blog
人人都是产品经理
人人都是产品经理
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
Martin Fowler
Martin Fowler
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
A
About on SuperTechFans
V
V2EX
P
Proofpoint News Feed
腾讯CDC
S
Schneier on Security
K
Kaspersky official blog
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CERT Recently Published Vulnerability Notes
aimingoo的专栏
aimingoo的专栏
博客园 - 叶小钗
美团技术团队
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
C
Cisco Blogs
PCI Perspectives
PCI Perspectives
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 【当耐特】
N
News and Events Feed by Topic
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
P
Privacy International News Feed
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
W
WeLiveSecurity
Spread Privacy
Spread Privacy
S
Securelist

博客园 - 蒋建华

使用SharePoint 2010 Management Shell修改SharePoint 2010 身份认证方式的两种方法 推荐几款兼容移动终端和PC终端的UI控件 八大免费SharePoint MasterPage 和Theme 一个完整的微软官方提供的SharePoint 2010 完整模板 Sample Master Pages for SharePoint 2010 Windows 7下安装SharePoint Server 2010指南 使用Create EndPoint创建本机XML Web Service 将PD的物理模型导入Erwin 使用PowerDesigner 15生成SQL Server中文注释 私有云、公有云与传统数据中心 ORM及相关技术概念入门 SharePoint 2010企业应用解决方案 微软云计算解决方案之特性及案例分析 不竭动力:云计算中虚拟化管理详解 云协作新利器:微软SharePoint Online 云计算版的PC管理工具:Windows Intune PetShop与ORM架构的比较 私有云:构建DDC测试环境需求分析 教你如何安装配置动态数据中心测试环境
Workflow4 持久化之数据库模型
蒋建华 · 2011-08-29 · via 博客园 - 蒋建华

Workflow4 持久化之数据库模型

概述

在没有持久化之前,流程实例只能在内存中短期运行,一旦流程需要长期运行,这就需要预先将工作流保存并在将来重新加载,也就是工作流的持久化。Workflow 4WF4)将工作流持久化作为一个可选的插件来提供持久化的服务,并通过调用SqlWorkflowPersistenceService类来实现SQL Server数据中Workflow的持久化。

工作原理

工作流持久化通过开启工作流持久化服务来进行持久化。在初始化工作流运行时引擎时加载一次,这样工作流运行时引擎就会在工作流生命周期中的指定时间来保存或加载工作流实例。这里的指定时间有以下几种情况:

(1)      工作流空闲时

(2)      工作流完成或终止时

(3)      活动TransactionScopeActivity/CompensatableTransactionScopeActivity/CompensatableSequenceActiviy完成时

(4)      自定义活动完成时

(5)      调用WorkflowInstance的一种方法,且这种方法又会导致持久性操作时

对开发者来说,不需要额外去控制持久化服务,流程实例的持久化是由工作流运行时引擎去自动控制的。

WF4 数据模型

WF4的物理模型

WF4的数据库

SQL

建表

SqlPersistenceProviderSchema.sql

InstanceData 实例数据表

SqlPersistenceService_Schema.sql

InstanceState 实例状态表

CompletedScope 完成范围

SqlWorkflowInstanceStoreSchema.sql

[System.Activities.DurableInstancing].[InstancesTable] 实例表

[System.Activities.DurableInstancing].[RunnableInstancesTable] 运行实例表

[System.Activities.DurableInstancing].[KeysTable] 关键字表

[System.Activities.DurableInstancing].[LockOwnersTable] 锁定表

[System.Activities.DurableInstancing].[InstanceMetadataChangesTable] 实例元数据变化表

[System.Activities.DurableInstancing].[ServiceDeploymentsTable] 服务部署表

[System.Activities.DurableInstancing].[InstancePromotedPropertiesTable] 实例属性表

[System.Activities.DurableInstancing].[SqlWorkflowInstanceStoreVersionTable] 实例版本表

[System.Activities.DurableInstancing].[Instances] 实例View

[System.Activities.DurableInstancing].[ServiceDeployments] 服务部署view

[System.Activities.DurableInstancing].[InstancePromotedProperties] 实例属性view

Tracking_Schema.sql

ActivityExecutionStatus 活动执行状态

[Type] 类型

[Workflow] 流程

[Activity] 活动

[WorkflowInstance] 工作流实例

[ActivityInstance] 活动实例

[ActivityExecutionStatusEvent] 活动执行状态事件

[UserEvent] 用户事件

[TrackingWorkflowEvent] 跟踪工作流事件

[WorkflowInstanceEvent] 工作流实例事件

[TrackingDataItem] 跟踪数据项

[TrackingDataItemAnnotation] 跟踪数据项注释

[EventAnnotation] 事件注释

[AddedActivity] 增加活动

[RemovedActivity] 删除活动

[TrackingPartitionInterval] 跟踪分区间隔

[TrackingPartitionSetName] 跟踪分区名称

[TrackingProfile] 跟踪概况

[TrackingProfileInstance] 跟踪实例

[DefaultTrackingProfile] 默认跟踪概况

视图

[vw_ActivityExecutionStatus] 活动执行状态View

[vw_Type] 类型View

[vw_Workflow] 工作流View

[vw_Activity] 活动View

[vw_WorkflowInstance] 流程实例View

[vw_ActivityInstance] 活动实例

[vw_ActivityExecutionStatusEvent] 活动执行状态事件View

[vw_TrackingWorkflowEvent] 跟踪工作流事件View

[vw_WorkflowInstanceEvent] 工作流实例事件

[vw_UserEvent] 用户事件View

[vw_TrackingDataItem] 跟踪数据项View

[vw_TrackingDataItemAnnotation] 跟踪数据项解释View

[vw_EventAnnotation] 事件解释View

[vw_AddedActivity] 增加活动View

[vw_RemovedActivity] 删除活动View

[vw_TrackingProfile] 跟踪概况View

[vw_TrackingProfileInstance] 跟踪概况实例View

[vw_DefaultTrackingProfile] 默认跟踪概况View

[vw_TrackingPartitionInterval] 跟踪分区间隔View

[vw_TrackingPartitionSetName] 跟踪分区名称View

建表过程

1SqlPersistenceProviderSchema.sql

2SqlPersistenceService_Schema.sql

3SqlWorkflowInstanceStoreSchema.sql

4Tracking_Schema.sql

WF4持久化服务 VS 自定义持久化

在前面我们讲了WF4通过开启持久化服务来持久流程实例,在实际的项目中也可以完全自定义工作流持久化的数据模型和服务,下面我们来进行一个比较。

优点

缺点

WF4持久化

1、能够比较方便利用现有的建表脚本创建持久化需要的数据库表

2、不用关心流程实例持久化发生的时间,运行时引擎会自动处理

3、不用关心如何实现持久化这些技术细节

4、有现有的服务接口可以调用,可扩展

5、完成对流程实例整个生命周期的管理

6、同WF 4现有的API易于集成和工作

1、仅仅使用现有的表是不够的,还需要自定义进行扩展数据库表,如一些设置和参数信息

2、无法控制流程持久化的时间,需要使用持久化的数据时,数据可能并没有被持久化

3、受持久化现有服务和接口的制约

4、需要对现有的一些数据库表进行扩展,这些扩展中的数据和已建表的一些数据要做到同步,增加了事件、事务处理的复杂度

5、开发进度和质量依赖与对SqlWorkflowPersistenceService的掌握程度

6、流程处理的性能需要验证

7WF4所带数据库是一个黑盒,没有相关的文档说明和数据库设计文档

自定义持久化

1、能根据用户需求完全自定义数据结构和模型

2、能够控制持久化的时机,对流程数据具有完全的权限

3、降低了流程数据持久化的技术难度

4、统一设计数据模型,减少流程中的事务处理和数据关联关系

5、针对用户需求来进行设计

1、需要自行设计数据库模型

2、不能使用WF4 提供现有持久化接口和流程管理与监控的一些功能,这些功能需要自定义开发

3、开发工作量相对较大,但是技术难度会有所降低

结论:

在不了解WF4持久化服务的工作原理和SqlWorkflowPersistenceService类库的情况下,可以使用自定义持久化方案来进行持久化。有关使用WF4进行持久化的应用实践,需要做技术验证。