locked
long running workflows RRS feed

  • Question

  • Hello,

    I am implementing a long running workflow. my workflow may pass by many stages:

    started, running ,pending,and Complete.

    i am using the PersistableIdle event to unload the wf when it becomes idle, and reloads it later by using the same instance id.

    I have a problem: the workflow is not unloaded from memory when i use bookmark.

    i want the wf to read the object passed by the bookmark, unloads from memory

    and resumes later when i reload it.how can i do this ?Please help me.   

    static void StartInstance(Activity ac, CustomBookmark bm, InstanceStore store, ObjectSpace wfObjectSpace) WorkflowApplication application = new if (!wfObjectSpace.Session.InTransaction)

     

    bm.Save();

    wfObjectSpace.Session.CommitTransaction();

    }

    };

    WorkflowState.Completed;

    if (!wfObjectSpace.Session.InTransaction) }

    {

    wfObjectSpace.Session.BeginTransaction();

    }

    bm.InstanceId= application.Id;

    bm.Save();

    wfObjectSpace.Session.CommitTransaction();

    application.ResumeBookmark(bm.Name,bm.Object);

     

     

     

    {

    wfObjectSpace.Session.BeginTransaction();

    bm.WorkflowState =

    WorkflowState.Pending ; if (!wfObjectSpace.Session.InTransaction)

     

    bm.Save();

    wfObjectSpace.Session.CommitTransaction();

    }

    };

    WorkflowState.Completed;

    if (!wfObjectSpace.Session.InTransaction) }

    {

    wfObjectSpace.Session.BeginTransaction();

    }

    bm.InstanceId= application.Id;

    bm.Save();

    wfObjectSpace.Session.CommitTransaction();

    application.ResumeBookmark(bm.Name,bm.Object);

     

     

    }

     

    bm.Save();

    wfObjectSpace.Session.CommitTransaction();

    }

    };

     application.Completed = (workflowApplicationCompletedEventArgs) =>

    {

     

    };

    application.Unloaded = (e) =>

    {

    instanceUnloaded.Set();

     

    {

    wfObjectSpace.Session.BeginTransaction();

    bm.WorkflowState =

    Monday, September 27, 2010 5:30 AM

Answers

  • Hi, Ali

    ->"but when i start it with resumeBookmark the workflow is not stored in the instance store."
    By default, all persisted instance will be deleted from persistence database when the workflow finished execution.
    If you want to leave all the persistence data in the database. if can use the following code:

    sqlWFInstanceStore.InstanceCompletionAction=InstanceCompletionAction.DeleteNothing;

    Hope it helps
    Regards


    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com "Microsoft Windows Workflow Foundation 4.0 Cookbook"
    • Marked as answer by Andrew_Zhu Monday, October 4, 2010 7:51 AM
    Tuesday, September 28, 2010 8:41 AM

All replies

  • Have you set up an instance store for the WorkflowApplication object? If so, have you tried execuing queries against your instance store to make sure that persistence is happening?

    How are you determining that the workflow is staying in memory?

    Are you using an AsyncCodeActivity? The runtime automatically executes an AsyncCodeActivity in a no-persist zone, since the runtime has no visibility into the work that this activity does asynchronously.

    • Proposed as answer by gogolojiBanned Monday, September 27, 2010 6:38 PM
    Monday, September 27, 2010 5:56 PM
  •  I set up the instance store for the workflow, and the workflow is unloaded from memory properly.

    i can unload , and reload it back. but when i start it with resumeBookmark the workflow is not stored in the instance store.

    I need to do the following steps:

    1-start this workflow with resumeBookmark (pass the parameters to the workflow)

    2-continue execution , when it becomes idle unload  from memory

    3-reload the workflow when necessary

    4-finish the workflow

     

    Monday, September 27, 2010 6:21 PM
  • Hi, Ali

    ->"but when i start it with resumeBookmark the workflow is not stored in the instance store."
    By default, all persisted instance will be deleted from persistence database when the workflow finished execution.
    If you want to leave all the persistence data in the database. if can use the following code:

    sqlWFInstanceStore.InstanceCompletionAction=InstanceCompletionAction.DeleteNothing;

    Hope it helps
    Regards


    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com "Microsoft Windows Workflow Foundation 4.0 Cookbook"
    • Marked as answer by Andrew_Zhu Monday, October 4, 2010 7:51 AM
    Tuesday, September 28, 2010 8:41 AM