WWF:SqlWorkflowInstanceStoreBehavior 与 SqlWorkflowInstanceStore

WWF: SqlWorkflowInstanceStoreBehavior verus SqlWorkflowInstanceStore

我有一个 Windows 服务包装了一个 WCF 服务,它包含一个运行活动的 WorkflowApplication。我还配置了 SQL Server 2008 Express(我知道,它接近 EOL,但文档明确指出仅支持 SQL Server 2005 或 SQL Server 2008)来托管数据库和连接 有效 。更清楚: Activity 的整个过程完成并接收 return (我通过包装在 PowerShell 中的 WCF 客户端调用它)。

我遇到的问题是我在 ServiceHost 上配置了 SqlWorkflowInstanceStoreBehavior 并且在 WorkflowApplication 上配置了 SqlWorkflowInstanceStore。这些都不会引发 SQL 异常,但我 认为 ServiceHost 正在采取预防措施,因为我所看到的只是 LockOwnersTable 上的单个条目。

来自 Windows 服务的代码:

        this.obj = new ServiceHost(typeof(WorkflowService));
        SqlWorkflowInstanceStoreBehavior instanceStoreBehavior = new SqlWorkflowInstanceStoreBehavior("Server=.\SQL2008EXPRESS;Initial Catalog=WorkflowInstanceStore;Integrated Security=SSPI")
        {
            HostLockRenewalPeriod = TimeSpan.FromSeconds(5),
            InstanceCompletionAction = InstanceCompletionAction.DeleteNothing,
            InstanceLockedExceptionAction = InstanceLockedExceptionAction.AggressiveRetry,
            InstanceEncodingOption = InstanceEncodingOption.GZip,
            RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(2)
        };
        this.obj.Description.Behaviors.Add(instanceStoreBehavior);
        this.obj.Open();

来自 WCF 的代码 Service/WorkflowApplication:

        SqlWorkflowInstanceStore newSqlWorkflowInstanceStore = new SqlWorkflowInstanceStore("Server=.\SQL2008EXPRESS;Initial Catalog=WorkflowInstanceStore;Integrated Security=SSPI")
                                                        {
                                                            EnqueueRunCommands = true,
                                                            HostLockRenewalPeriod = TimeSpan.FromSeconds(5),
                                                            InstanceCompletionAction = InstanceCompletionAction.DeleteNothing,
                                                            InstanceLockedExceptionAction = InstanceLockedExceptionAction.BasicRetry,
                                                            RunnableInstancesDetectionPeriod = TimeSpan.FromSeconds(5)
                                                        };
        InstanceHandle workflowInstanceStoreHandle = newSqlWorkflowInstanceStore.CreateInstanceHandle();
        CreateWorkflowOwnerCommand createWorkflowOwnerCommand = new CreateWorkflowOwnerCommand();
        InstanceView newInstanceView = newSqlWorkflowInstanceStore.Execute(workflowInstanceStoreHandle, createWorkflowOwnerCommand, TimeSpan.FromSeconds(30));
        newSqlWorkflowInstanceStore.DefaultInstanceOwner = newInstanceView.InstanceOwner;

        // Now stage the WorkflowApplication, using the SQL instance.
        AutoResetEvent syncEvent = new AutoResetEvent(false);
        WorkflowApplication newWorkflowApplication = new WorkflowApplication(unwrappedActivity)
                                                         {
                                                             InstanceStore = newSqlWorkflowInstanceStore
                                                         };

问题:

  1. ServiceHost SqlWorkflowInstanceStoreBehavior 是否覆盖 WorkflowApplication 上的 SqlWorkflowInstanceStore?如果是这样,显而易见的答案是删除 ServiceHost 上的 SqlWorkflowInstanceStoreBehavior;然而,正如之前推断的那样,我担心这将证明是徒劳的,因为 WorkflowApplication 目前没有记录任何东西(据我所知,甚至没有尝试记录)。

  2. ASAppInstanceService 似乎特定于 WindowsServer。如果 ServiceHost(通过 Windows 服务选项)总是 将 Windows 10 托管那些(对于 dev/pre-production)是可能的=44=] WorkflowApplication 从进行 SQL 调用?

找出答案:

newWorkflowApplication.Persist();