「WWF」をワークフロー エンジンとして使用しているシステムがあり、ワークフローを続行するリクエストが頻繁に失敗し、ログがこの例外でいっぱいになります。
System.Runtime.DurableInstancing.InstancePersistenceException : SqlWorkflowInstanceStore ロックがデータベースに存在しません。これは、SQL Server がビジーであるか、接続が一時的に失われたために発生した可能性があります。
そしてそれはこれで発火しますevent (application.Aborted = (e) =>{})
、この問題を解決する方法についてのアイデアはありますか?
ワークフローをロードしてロックを解除する方法は次のとおりです
//Create an instance of the workflow and its application and associate with workflow application.
Activity workflow = Activator.CreateInstance(workflowType) as Activity;
WorkflowApplication application = new WorkflowApplication(workflow);
application.SynchronizationContext = SyncSynchronizationContext.SingletonInstance;
//Hold the workflow store
application.InstanceStore = CreateInstanceStore(WorkflowDatabaseConnectionString);
var instanceHandle = application.InstanceStore.CreateInstanceHandle(guid);
var ownerCommand = new CreateWorkflowOwnerCommand();
var view = application.InstanceStore.Execute(instanceHandle, ownerCommand, TimeSpan.FromDays(30));
application.InstanceStore.DefaultInstanceOwner = view.InstanceOwner;
// Do whatever needs to be dome with multiple WorkflowApplications
if (pParticipant != null)
application.Extensions.Add(pParticipant);
//Register workflow application services from the external world
ExternalRegisteredServices.ForEach(service => application.Extensions.Add(service));
ReadOnlyCollection<BookmarkInfo> currentBookmarks = null;
Dictionary<string, object> wfContextBag = null;
application.PersistableIdle = (workflowApplicationIdleEventArgs) =>
{
currentBookmarks = workflowApplicationIdleEventArgs.Bookmarks;
wfContextBag = workflowApplicationIdleEventArgs
.GetInstanceExtensions<WorkflowContext>()
.First()
.GetBag();
return PersistableIdleAction.Unload;
};
application.OnUnhandledException = (e) =>
{
if (wfUnhandledExceptionEventHandler != null)
wfUnhandledExceptionEventHandler(e);
return UnhandledExceptionAction.Abort;
};
application.Aborted = (e) =>
{
if (wfAbortedEventHandler != null)
wfAbortedEventHandler(e);
};
application.Completed = (e) =>
{
if (wfCompletedEventHandler != null)
wfCompletedEventHandler(e);
};
application.Load(guid);
BookmarkResumptionResult resumptionResult = BookmarkResumptionResult.NotFound;
if (!string.IsNullOrEmpty(bookmarkName))
resumptionResult = application.ResumeBookmark(bookmarkName, null);
if (resumptionResult != BookmarkResumptionResult.Success)
currentBookmarks = application.GetBookmarks();
var deleteOwnerCommand = new DeleteWorkflowOwnerCommand();
application.InstanceStore.Execute(instanceHandle, deleteOwnerCommand, TimeSpan.FromSeconds(30));
instanceHandle.Free();