开发者

Error loading a persisted workflow

开发者 https://www.devze.com 2023-02-03 19:59 出处:网络
I have a workflow started and persisted using messaging activities. The correlation between the Start initial command and the Stop final command works well if they\'re sent within few seconds.

I have a workflow started and persisted using messaging activities. The correlation between the Start initial command and the Stop final command works well if they're sent within few seconds. Problems begin when the workflow is unloaded, because the following Stop message throws the following FaultException:

If LoadWorkflowByInstanceKeyCommand.AssociateLookupKeyToInstanceId is not specified, the LookupInstanceKey must already be associated to an instance, or the LoadWorkflowByInstanceKeyCommand will fail. For this reason, it is invalid to also specify the LookupInstanceKey in the InstanceKeysToAssociate collection if AssociateLookupKeyToInstanceId isn't set

Can anybody help me? The variables inside the workflow are of types int and XDocument. This is the code to initialize the WorkflowServiceHost:

WorkflowServiceHost serviceHost = new WorkflowServiceHost(myWorkflow, new Uri(serviceUri));
            ServiceDebugBehavior debug = serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
            if (debug == null)
            {
                debug = new ServiceDebugBehavior();
                serviceHost.Description.Behaviors.Add(debug);
            }

            debug.IncludeExceptionDetailInFaults = true;
            WorkflowIdleBehavior idle = serviceHost.Description.Behaviors.Find<WorkflowIdleBehavior>();
            if (idle == null)
            {
                idle = new WorkflowIdleBehavior();
                serviceHost.Description.Behaviors.Add(idle);
            }

            idle.TimeToPersist = TimeSpan.FromSeconds(2);
            idle.TimeToUnload = TimeSpan.FromSeconds(10);
            var behavior = new SqlWorkflowInstanceStoreBehavior
            {
                ConnectionString = ConfigurationManager.ConnectionStrings["WorkflowPersistence"].ConnectionString,
                InstanceEncodingOption = InstanceEncodingOption.None,
                InstanceCompletionAction = InstanceCompletionAction.DeleteAll,
                InstanceLockedExceptionAction = InstanceLockedExceptionAction.BasicRetry,
                HostLockRenewalPeriod = new TimeSpan(00, 00, 30),
                RunnableInstancesDetectionPeriod = new TimeSpan(00, 00, 05)
            };
            serviceHost.Description.Behaviors.Add(be开发者_JS百科havior);
            serviceHost.Open();

Looking at the database, it seems that the workflow is never suspended.

Any help appreciated, thank you


Not really sure what is going on here but it sounds like there are types used in the workflow that cannot be serialized and prevent the workflow from being stored to disk. When you say "Looking at the database, it seems that the workflow is never suspended." do you really mean suspended? And why do you expect the workflow to be suspended?

What happens if you send just the start message to the workflow and wait 2 seconds? Do you get a new record in the persistence database?

0

精彩评论

暂无评论...
验证码 换一张
取 消