locked
Reloading of persisted Workflows RRS feed

  • Question

  • After one workflow instance (for example of type Sequence) has been persisted persisted I would like to reload it again. For this reason I used
    folowing code:

     


    PersistenceProvider
    p = persistenceProviderFactory.CreateProvider(new Guid("b4b2be46-d8a3-458b-a517-4393c481928b"));
    WorkflowElement el = new Sequence();
    WorkflowInstance instance = WorkflowInstance.Load(activity, p);

    I'm not sure that this is the only and the best way to do this. Assuming that it is, it is strange to me that first argument of Load method is activity instance. Wouldn't be better to have a method Load(Guid instanceId) only?

    Similar mehtod we have in WF3 Runtime.GetWorkflow(Guid).
    If Workflow type isrequired it can be obtained by workflowInstance.Definition;

    Method "Load(guid)" would allow one to implement host which reaload any kind of workflow type. It would also be intersting to know how Dublin-Team deals with this requirement?!

    Damir

    Saturday, June 6, 2009 10:52 PM

Answers

All replies

  • There is a significant difference between WF3 and WF4 i.e

    WF3 - persistence is added on runtime which is same for all instances.
    WF4 - the persistence is added per instance.

    So now you need to provide the instance and persistence provider to instantiate a new WorkflowInstance using the persisted point of the old activity instance.

    You can have different persistence providers configured and added them to different instances. How does WorkflowInstance know where all to query the guid?
    Saurabh Chechi - MS Workflow SDET
    Monday, June 8, 2009 8:57 PM
  • Hi Saurabh,

    It might be a bit miss understandable, but in the example above is to me obvious that persisting is related to instance in WF.40. I like this, but my point is more about the signature of Load(?) method.

    1.      
    I do not see why activity instance is needed. In the case you have described, you can reuse the “old” activity instance as .Load(oldInstance, provider);

    This is fine, but in real long living Workflow scenario after restart of service I will not have activity instance. Moreover, after persisting of an instance I will for sure try to dispose unused instances. So the question is why do we need it if we don't have it?

    2.  Last but not least Load(Guid) seems to be enough? Another possibility: How about: Load<TWorkflow>(Guid)

    Thanks

    Damir

    Monday, June 8, 2009 9:31 PM
  • Hi Damir,

    I am sorry for confusion. The WorkflowInstance.Load method takes WorkflowElement as parameter not the instance. So you will need to pass only the activity definition and the persistence provider.

    I dont understand the confusion. Why do you want to keep track of guid of the instance? when you only need to provide the activity definition to load it back.
    Saurabh Chechi - MS Workflow SDET
    Monday, June 8, 2009 10:20 PM
  • No Problem Saurabh :)


    "Why do you want to keep track of guid of the instance? when you only need to provide the activity definition to load it back."



    What if I have N instances of Sequence1-activity and have provider shich can do following:

    List<Guid> instances = MySuperProvider.QueryInstances(i=>i.PersistedTime > 10\10\3001 && i.Priority == 1);

    So I can specifically load instance which I need.

    In example here (already shown above) I do not know which of instances will be loaded. I only know that it will be of type Sequence1. The question is which one?

    PersistenceProvider p = persistenceProviderFactory.CreateProvider(new Guid("b4b2be46-d8a3-458b-a517-4393c481928b"));
    WorkflowElement el = new Sequence
    ();
    WorkflowInstance instance = WorkflowInstance
    .Load(activity, p);

    Monday, June 8, 2009 10:29 PM
  • As far as I know you can only load the last persisted instance state.
    Saurabh Chechi - MS Workflow SDET
    Monday, June 8, 2009 11:33 PM
  • <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-520092929 1073786111 9 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:595.3pt 841.9pt; margin:70.85pt 70.85pt 2.0cm 70.85pt; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

    I do not think that this satisfies business needs. But this is not a problem, because one could implement custom provider. Anyhow, I would like to know what is then really the concept and idea behind Load()-Method related to discussion above?

    Tuesday, June 9, 2009 7:18 AM
  • ?

    Thursday, June 11, 2009 11:54 AM
  • Hi Damir,

    I am sorry I do not understand the question. The Load() parameters seem intuitive enough to me since you are asked to provide the activity definition and persistence provider. From your example WorkflowInstance.Load<TWorkflow>(Guid) how will you identify which persistence store to query the instance?


    Saurabh Chechi - MS Workflow SDET
    Friday, June 12, 2009 6:44 PM
  • Hi Saurabh,

    all I want to say is, I think WF4.0 should provide following Load signatures:

    Load(Guid, Provider)
    Load<TWorkflow>(Guid, Provider)

    But,can be that the binary data which contains one persisted activity, do not have knowledge about activity (workflow element type)? This might be the reason why WF provides Load(WorkflowElement, Provider) signature.

    Sunday, June 14, 2009 9:57 PM