views:

830

answers:

1

Hi

I have a workflow application which throws error when i try to invoke a event using ExternalDataExchangeService.

Workflow with id "866568ab-ca1b-4404-a2f1-2c8704539ef4" not found in state persistence store.

Event "QAEngOrTLReject" on interface type "RecipeChangeService.IRecipeChangeService" for instance id "866568ab-ca1b-4404-a2f1-2c8704539ef4" cannot be delivered.

Here is my implementation code for it - Please help I am stuck :(

Below is the interface and data exchange event args -

 
public class RecipeChangeService : IRecipeChangeService{
        #region IRecipeChangeService Members

        public event EventHandler QAEngOrTLApprove;

        public event EventHandler QAEngOrTLReject;

public bool QAEngOrTLApproved(Guid instanceId, ResponseDataObject rdo) {
            if (QAEngOrTLApprove != null) {
                QAEngOrTLApprove(this, new XMESWFRecipeResponseDataEventArgs(rdo, instanceId));
                return true;
            }return false;

        }

      public  bool QAEngOrTLRejected(Guid instanceId, ResponseDataObject rdo) {
            if (QAEngOrTLReject != null) {
                QAEngOrTLReject(this, new XMESWFRecipeResponseDataEventArgs(rdo,instanceId));
                return true;
            } return false;
        }
}

[Serializable]
    public class XMESWFRecipeResponseDataEventArgs : ExternalDataEventArgs {
        public readonly ResponseDataObject rdo = null;
        public XMESWFRecipeResponseDataEventArgs(ResponseDataObject rdo, Guid instanceId)
            : base(instanceId) 
        {
            this.rdo = rdo;
        }
    }

The event is raised using -



 IRecipeChangeService s =
                   ExceptionServices.GetExceptionService(WorkflowExceptionType.RecipeChange)
                   as IRecipeChangeService;
  s.QAEngOrTLApproved(new Guid(instanceId), rdo);

Thanks .

+3  A: 

Do us a favour and please make sure the code is readable.

There can be a number of reasons the workflow cannot be found. First of all you will also see this error if there is no persistence service and the workflow isn't in memory. Another thing to check is if the workflow hasn't completed yet. This can be either as the result of some other event or because of an unhandled error.

Maurice
I have added persistence service declaratively. How should I make sure if its properly working. I am certain that workflow is in memory and is not completed.
ksa
Open up the database where you are persisting the workflows and check the InstanceState table. There should be a record for each known workflow.You can check if your workflow is in memory using the GetLoadedWorkflows() function. If it isn't there you could be using a wrong workflow InstanceId or maybe have multiple workflow runtimes and using a different one from where you started the workflow.
Maurice
My InstanceState table is empty. That means no worklfows are persisted. How do I make sure when a instance is saved to database by persistence service.
ksa
If you set the UnloadOnIdle option to true on the SqlWorkflowPersistenceService it will persist any workflow as soon as it goes idle. So using a DelayActivity will make it go idle and persist. Alternatively use the WorkflowInstance.Unload() function to manually unload it.
Maurice
One thing I forgot to mention is that the workflow runtime will only go to the SqlWorkflowPersistenceService is the specified worklfow is not in memory. So judging from your original question you might be looking at this from the wrong angle. Where did you get the workflow instanceId from and if it was a valid workflow instance then what happend to it?
Maurice
The workflow instance are getting initiated as I see entry in WorkflowInstance table. Since this is a state machine workflow, first state event too if getting fired after which it should wait for an external event to happen in EventDriven activity in state-2. But I see entry for WorkflowStart time and WorkflowEnd time, This means workflow is getting completed and not persisted, so when my actual event for State-2 is called, it does not found it in persistence store. Now I need to find out why there is end time entry, Any clue, Shall I post my xoml?
ksa
Are you using any custom property types in your workflow? If so make sure all of them are decorated with the Serializable attribute. The WF runtime uses the binary serializer so everything in the workflow must be serializable using is.Also try hooking up the WorkflowTerminated, WorkflowCompleted and WorkflowAborted events and check which is firing and for what reason. Another useful thing is to enable workflow tracking and workflow tracing to see what is happening.
Maurice
Thanks a lot Maurice. I have found the problem, I was using my custom data exchange object and at one place I missed [Serializable] attribute on a class. Many Thanks to you once again.
ksa