WWF: SqlWorkflowInstanceStoreBehavior verus SqlWorkflowInstanceStore

本小妞迷上赌 提交于 2019-12-13 04:39:49

问题


I have a Windows Service wrapping a WCF Service, which contains a WorkflowApplication, which runs Activities. I have also configured SQL Server 2008 Express (I know, it's approaching EOL, but the documentation explicitly states that only SQL Server 2005 or SQL Server 2008 are supported) to host the database and the connection works. To be even clearer: The entire process of the Activity completes and receives the return (I'm calling it via the WCF client wrapped in PowerShell).

The issue that I'm having is that I've configured SqlWorkflowInstanceStoreBehavior on the ServiceHost and SqlWorkflowInstanceStore on the WorkflowApplication. Neither of these throws a SQL exception but I think that the ServiceHost is taking precidence, as all that I can see is a singe entry on the LockOwnersTable.

Code from Windows Service:

        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();

Code from 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
                                                         };

Questions:

  1. Does the ServiceHost SqlWorkflowInstanceStoreBehavior override the SqlWorkflowInstanceStore on the WorkflowApplication? If so, the obvious answer would be to remove the SqlWorkflowInstanceStoreBehavior on the ServiceHost; however, as inferred before, I fear that will prove fruitless, as the WorkflowApplication currently isn't logging anything (or even attempting to, from what I can tell).

  2. ASAppInstanceService seems specific to WindowsServer. Is is possible to host those (for dev/pre-production) on Windows 10, if the ServiceHost (via Windows Service option) is always going to block/disable the WorkflowApplication from making the SQL calls?


回答1:


Figued out the answer:

newWorkflowApplication.Persist();


来源:https://stackoverflow.com/questions/54535259/wwf-sqlworkflowinstancestorebehavior-verus-sqlworkflowinstancestore

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