locked
Custom Persistence and CompletedScope table RRS feed

  • Question

  • I have just successfully completed a custom persistence service for MySQL. I have been digging into some of the other tables associated with the SQL persistence schema and stored procs. I came across the table CompletedScope. I did find a thread on it saying it is used to hold completed activites derived from ICompensatableActivity.

    My question is how do I add custom support for this table into my custom persistence? I see no examples or discussion on this.

    Thanks

    Bill

    Wednesday, August 2, 2006 1:04 PM

Answers

  • Bill,

    We get the value of the completeScopeActivity as  a StateID and then add it to the WorkBatch, as an item.  The ScopeID is the StateID.

    Thursday, August 3, 2006 2:49 PM
  • The ContextGuid is the id of the activity's context.  I don't know that we guarantee that the ContextGuid for the root activity is always the same as the instance id.  Probably but I'd just use the instance id for the root activity - you only need the instance id for SaveWorkflowInstanceState.  For the activity that is passed to SaveCompletedScope you want to use the instance id (to identify which instance the context belongs to) and the context guid (to uniquely identify the context within that instance).  In the SqlWorkflowPersistenceService these are saved in the uidInstanceID and completedScopeID columns.

    Thanks,

    Joel West

    MSFTE - SDE in WF runtime and hosting

    This posting is provided "AS IS" with no warranties, and confers no rights

     

    Thursday, August 3, 2006 5:15 PM

All replies

  • Have you tried going thru the stored procedures in the WF documentation? I'd start there...
    Thursday, August 3, 2006 2:15 PM
  • Yes I did. I am using Reflector to examine the assemblies. I noticed that the AddInstance SP will delete an entry from the CompletedScope table if it is completed or terminated.

    I also located the a method called SaveCompletedContextActivity under the SqlPersistenceService. It places some info into class container and it is added to the WorkEnvironment.WorkBatch which (I believe) is used by the transaction service to perfom batch updates, etc. Eventually the InsertCompletedScope method under the PersistanceDbAccesor is called to insert the info into the CompletedScope table.

    public void InsertCompletedScope(Guid instanceId, Guid scopeId, byte[] state)

    What I am trying to figure out is where the value of scopeId comes from. Is it the stateId value gathered by the SaveCompletedContextActivity method?

    protected internal override void SaveCompletedContextActivity(Activity completedScopeActivity)

    I am just wanting to be sure. I am hoping to create a generic persistence service to be used by any DB (MySql, Oracle, etc.).

    Thanks

    Bill

    Thursday, August 3, 2006 2:30 PM
  • Bill,

    We get the value of the completeScopeActivity as  a StateID and then add it to the WorkBatch, as an item.  The ScopeID is the StateID.

    Thursday, August 3, 2006 2:49 PM
  • Thanks for the clarification.

    One more question. What is the difference between the workflow instanceId () and the stateId? I found code that allows me to get the stateId. The rootActivity is pased into method.

                Guid guidProp = (Guid)rootActivity.GetValue(Activity.ActivityContextGuidProperty);
                item1.stateId = quidProp;            
                item1.instanceId = WorkflowEnvironment.WorkflowInstanceId;

    Just want to be sure I am doing things correctly.

    Thanks

    Bill

     

    Thursday, August 3, 2006 3:24 PM
  • The ContextGuid is the id of the activity's context.  I don't know that we guarantee that the ContextGuid for the root activity is always the same as the instance id.  Probably but I'd just use the instance id for the root activity - you only need the instance id for SaveWorkflowInstanceState.  For the activity that is passed to SaveCompletedScope you want to use the instance id (to identify which instance the context belongs to) and the context guid (to uniquely identify the context within that instance).  In the SqlWorkflowPersistenceService these are saved in the uidInstanceID and completedScopeID columns.

    Thanks,

    Joel West

    MSFTE - SDE in WF runtime and hosting

    This posting is provided "AS IS" with no warranties, and confers no rights

     

    Thursday, August 3, 2006 5:15 PM
  • Bill,

    Have you ever seen when is the LoadCompletedContextActivity or the SaveCompletedContextActivity are called?

    I'm testing the Oracle persistence service but I can't design a workflow to test those methods. I already used a CompensatableTransactionScopeActivity and a custom activity implementing the ICompensatable interface, but I couldn't test this methods... I put a breakpoint in those methods, and I use a delay activity but I doesn't work.

     

    Do you know how I can test them????

     

     

    Monday, October 1, 2007 3:51 PM
  • These methods will be called if your compensatable activities are placed inside multi context activities like While, Replicator, CAG, Eventhandler etc.

     

    Tuesday, October 2, 2007 3:59 PM