InstanceView RRS feed

  • Question

  • Hi,
    I would like to have some explanation for the following lines of code :

    InstanceView view = instanceStore.Execute(instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
                instanceStore.DefaultInstanceOwner = view.InstanceOwner;

    Why are they required and what is their utility?

    Karol Deland, Québec
    Friday, November 27, 2009 1:48 AM

All replies

  • CreateWorkflowInstance is used by a workflow host to register itself with an instance store. This registration needs to occur before the host can load and save instances from the store (ie execute any other commands). Once the host has finished with the store and has no more work to do the DeleteWorkflowOwnerCommand needs to be executed so the store can do any cleanup work required.

    It is possible that one instance store object can support many simultaneous owners. In the example above, the call to DefaultInstanceOwner is indicating to the store that any commands executed against the store that do not have an explicit owner assigned should use the value of DefaultInstanceOwner for the instance owner.

    Friday, November 27, 2009 5:44 PM
  • What I really want to know is why is it required to define a registration to the store before using it? Is it to manage multiple hosts in Dublin?

    Karol Deland, Québec
    Wednesday, December 2, 2009 2:34 AM
  • Registration allows the host to pass initialization information to the store - for example owner metadata that the store can use to correctly load/save/resume instances, among other things.

    This pattern also allows for the possibility of multiple owners, if the store choses to support it.

    Wednesday, December 2, 2009 4:15 AM
  • May be I'm a bit slow on that one. Why do I need an owner? When using a repository, the repository is responding to requests. Why should it know his owners before that? Is the SQLWorkflowInstanceStore using the owner thing to process request some other way when a specific owner is making a call or is it only an extensibility point of the framework that developpers can leverage when building a custom instance store?

    Karol Deland, Québec
    Wednesday, December 2, 2009 11:53 AM
  • For example owner registration is used for instance recovery & durable timers - these are tasks where the store is going to notify the host of work that can be done. As such it needs to know the set of owners for checking for instances that need to be recovered or timers that need to be fired.

    Wednesday, December 2, 2009 4:54 PM