locked
Bookmarks are not loaded on WorkflowApplication.Load(InstanceGuid) RRS feed

  • Question

  • I have some problems with bookmarks right now, the bookmarks are not loaded into the WorkflowApplication after loading a Workflow from persistance. And I don't have idea why.

    Here my code for loading from persistance:

    Activity act = WorkflowCorrelationManager.LoadActivity(instanceGuid);
    if (act == null)
    {
        continue;
    }
    
    WorkflowApplication wFApp = LoadWorkflowApplication(act);
    
    WorkflowRequestExtension requestExtension = new WorkflowRequestExtension();
    requestExtension.WorkflowRequestItemEvent += OnRequestItemEvent;
    wFApp.Extensions.Add(requestExtension);
    
    WorkflowTrackingParticipant trackingParticipant = new WorkflowTrackingParticipant();
    wFApp.Extensions.Add(trackingParticipant);
    
    WorkflowDebuggerExtension debuggerExtension = new WorkflowDebuggerExtension();
    debuggerExtension.RegisterTrackingParticipant(trackingParticipant);
    wFApp.Extensions.Add(debuggerExtension);
    
    wFApp.Load(instanceGuid);
    WfRuntimeEntries.Add(instanceGuid, new WorkflowInstanceRuntimeEntry(entity, wFApp));
    
    WfApps.Add(instanceGuid, wFApp);
    
    var k = wFApp.GetBookmarks();

    Then I just wait for the resuming event and it calls the following method

    internal static void Resume(IWorkflowRequestItem irToResume, object resumingEvent)
            {
                // 1.) Determine Runtime Entry
                WorkflowInstanceRuntimeEntry wIRE;
                var isResumable = WfRuntimeEntries.TryGetValue(irToResume.GetWorkflowGuid(), out wIRE);
    
                // 3.) Resume
                if (isResumable && wIRE.WfApp != null)
                {
                    Bookmark bokMark = new Bookmark(irToResume.GetBookmarkName());
                    // Calls "Resumed" Method of Suspended Activity Instance
                    var t = wIRE.WfApp.ResumeBookmark(bokMark, resumingEvent, new TimeSpan(1, 0, 0));
                }
            }

    The Workflow is resume, BUT, starts all over again, and then in the activity where the Bookmark was created, creates another bookmark, call the Resume method again and then continue normally.

    If the WorkflowHost is not stopped, the resuming works perfectly and continue directly from the activity who raise CreateBookmark.

    Please, any help, ideas, discussion or whatever?

    Thanks!

    Wednesday, November 5, 2014 3:30 PM

All replies

  • Hi,

    Please refer to the sample which might help you

    #Using WF4 bookmarks with IWorkflowInstanceExtension

    http://blogs.msmvps.com/theproblemsolver/2010/01/27/using-wf4-bookmarks-with-iworkflowinstanceextension/

    Thursday, November 6, 2014 7:17 AM
  • Hi Birdsven, first at all, thanks for your reply.

    I take a look on the example you give me, but seems to be oriented to WCF and use WorkflowInvoker, I have to use WorkflowApplication instead, because I have persistence on my workflow.
    Thursday, November 6, 2014 12:05 PM
  • I found what could be the problem, after the loading of the instace data and the metadata from the InstanceStore, there are no Bookmarks on the property of the WorkflowApplication.

    Is this normal? Or the bookmarks should also persisted on the DB? If yes, why are not persisted? and why I don't get a "not found" when I call the resume method?
    Thursday, November 6, 2014 3:07 PM