2011-12-06 41 views
2

返回也許任何你可以幫我這個是煩人的問題。我有很長時間運行的工作流程,這是長時間運行的應用程序使用的。
我使用SqlWorkflowInstanceStore進行持久化。
我設置DefaultInstanceOwner這樣我就可以重新加載應用程序的其他啓動工作流。InstanceOwnerException從睡眠

InstanceHandle handle = workflowInstanceStore.CreateInstanceHandle(); 
InstanceView view = workflowInstanceStore.Execute(handle, 
          new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30)); 
handle.Free(); 
workflowInstanceStore.DefaultInstanceOwner = view.InstanceOwner; 

,我在應用程序退出刪除:

var deleteOwnerCmd = new DeleteWorkflowOwnerCommand(); 
InstanceHandle handle = workflowInstanceStore.CreateInstanceHandle(); 
workflowInstanceStore.Execute(handle, deleteOwnerCmd, TimeSpan.FromSeconds(30)); 
handle.Free(); 

一切都在正常使用應用的順利。如果窗口進入睡眠模式,則會出現問題。當它從睡眠模式返回,其workflowInstanceStore任何其他操作拋出:

System.Runtime.DurableInstancing.InstanceOwnerException: The execution of an InstancePersistenceCommand was interrupted because the instance owner registration for owner ID 'GUID' has become invalid. This error indicates that the in-memory copy of all instances locked by this owner have become stale and should be discarded, along with the InstanceHandles. Typically, this error is best handled by restarting the host. 

我把在LockOwnersTable數據庫和鎖定期滿一看被設置爲2000-01-01 00:00: 00.000當系統喚醒時。

任何想法,以找到根本原因針對此行爲或解決方法是受歡迎的。我已經拿了第一個解決辦法,那就是禁用休眠模式...

+0

很有意思 - 如果我能重現此我想對文件中的錯誤。你有簡單的repro我可以看看嗎? –

+0

這裏同樣的問題。你有沒有找到其他解決方案? – olorin

+0

如果WorkflowInstanceOwner已失效,則解決方案確實會檢查系統恢復。 – AlexP

回答

1

我覺得這種行爲的原因,是工作流實例存儲應該告訴數據庫它仍然是在固定的時間間隔alived(由定義HostLockRenewalPeriod屬性)。當計算機處於睡眠模式時,它無法更新LockOwnersTable的LockExpiration列,並且工作流實例存儲被視爲不可用。

一個解決辦法是重新啓動實例存儲時從睡眠模式恢復電腦。 您可以通過註冊Microsoft.Win32.SystemEvents.PowerModeChanged事件來檢測此情況。