Error: EventDeliveryFailedException ?

I have got a dual WinForms/ASP.NET workflow application working, except for raising events to workflow from ASP.NET.

The events work ok if raised under WinForms app, with DefaultWorkflowScheduler. Under ASP.NET I raise the same event (same code in same DLL) I get the error below. The ASP.NET code raising the event is this:

ASP.NET Code:
'...Get the GUID of the task
Dim ID As String = Me.GridView1.SelectedRow.Cells(4).Text
Dim instanceID As New Guid(ID.Trim)

'get WF runtime and service
Dim wfr As WorkflowRuntime = Global.ASP.global_asax.workflowRuntime
Dim ccwf As CreditControlService = Global.ASP.global_asax.ccwf

Try
Dim task As WorkflowInstance = wfr.GetWorkflow(instanceID)
task.Load()

'Tell WF we have called customer (callback in 2 days)
'ccwf.CalledDIRECT(instanceID, Now.Date.AddDays(2))
ccwf.HaveCalledCustomer(instanceID, Now.Date.AddDays(2))
Me.errors.Text = "Workflow updated"

'process this (manual scheduler)
Global.ASP.global_asax.manualWF.RunWorkflow(instanceID)


Catch ex As Exception
Me.errors.Text = "Error: " & ex.Message

End Try


The workflow is a State workflow, which has an event handler, with a handleExternalEventActivity handler in it awaiting this event.. as I say it works fine under WinForms so obviously something I am doing in ASP.NET is wrong!

Error that is raised:
System.Workflow.Activities.EventDeliveryFailedException was unhandled
Message="Event "CalledCustomerPromisedPayment" on interface type "WorkflowLibrary.ICreditControl" for instance id "ecda6031-945e-4a87-9e22-2c37c510a4b6" cannot be delivered."
Source="System.Workflow.Activities"
StackTrace:
at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)
at WorkflowLibrary.CreditControlService.HaveCalledCustomerEvent(Object args) in C:\WorkflowTest1\WorkflowLibrary\CreditControl.vb:line 87
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)




Answer this question

Error: EventDeliveryFailedException ?

  • Craig Mellon

    This doesn't fix the problem, but I switched my workflow over to a Sequential Workflow like they use in the ExpenseReport application. The workflow works fine and without the need of a correlation token.

    I used the SQL traking sample and everything is synchronized and flows as expected. I went ahead and changed values and persisted the object independant from the workflow and everything pans out.

    So, since I didn't change my events, event args, or anything but the workflow. This leads me to believe that the difference is between sequential and state workflow local communications.

    I know this is not an answer to the problem, but hopefully it will get us closer to a solution.

    Take care,

    John


  • tmakaro

    Having looked up correlation tokens I don't think they would be required This is a state machine, and there are no parallel activities. Unless one counts the various event-driven activities which can happen at different points.



  • RobertBarnes

    Can you post the entire stack trace Are you using correlation Is the correlation token properly initialized

    Thanks,

    Vignesh



  • stevema

    I'm having the same problem in a sequential workflow that was recently updated to a new version. All versions are available in the GAC. The error is raised when trying to raise an external event on the workflow from an instance of the previous version. Can anyone provide some help As it is now I am stuck using the original workflow version and can't make any changes because changing anything breaks everything.



  • redhatws

    Thanks - that helps confirm what I suspected: it's a bug with State machine workflows.. or possibly we are missing some action that is required for State machines when used under ASP.NET in some set of circumstances - perhaps when Persistence is used..

    I took the MS ASP example workflow ( a sequential workflow) and added an event handler and it worked fine, which strongly confirms what you suggest: State machine is broken

    I think I will post it as a bug unless MS can explain what's missing



  • John Penberthy

    I am beginning to suspect my translation of C# into VB - perhaps the event handler in a C# service example..

      public event EventHandler<MyEventArgs> SomeEvent;

    Which from looking at VB examples (the MSDN helpdesk example), should translate to ..

      Public Event SomeEvent(ByVal sender As Object, ByVal e As MyEventArgs) Implements IMyInterface.SomeEvent


    I am sure this isn't right, as surely it should be

      Public Event SomeEvent As EventHandler(Of MyEventArgs) Implements IMyInterface.SomeEvent



  • Chris Howarth

    Thanks for the suggestion..

    I couldn't find an EnqueOnIdle flag as part of ExternalDataEventArgs (I am using beta2 - is it present on 2.2 ).

    There is a WaitForIdle flag but setting this resulted in the workflow blocking the ASP.NET thread to wait while it raised the event - except of course it would wait forever as it was ManualWorkflowScheduler



  • GraemeWT

    Did adding the correlation tokens fix the problem

    I am having the same problem and I was wondering why the ExpenseReport sample from Microsoft works. I don't see any correlation tokens in thier code.

    Any information that helps would be greatly appreciated.

    Thanks,

    John


  • hocki101

    Thanks for the help - nope - I already checked that my arguments were serializable.

    I am currently looking at an excellent PluralSight blog with an example that shows a workflow across ASP.NET, WinForms and Console.

    I just don't seem to be able to get the raising events to work in my application.


  • Ximena Cardenas

    Having looked, the inner exception is:

    System.InvalidOperationException: Event Queue operation failed with MessageQueueErrorCode QueueNotFound for queue 'Message Properties
    Interface Type:WorkflowLibrary.ICreditControl
    Method Name:CalledCustomerPromisedPayment
    CorrelationValues:



  • Flashster

    Howard -

    State machine does have a minor difference. You will have to set the EnqueueOnIdle flag to true before sending messages to avoid problems with delivering messages to sinks not in the current state of the state machine.

    Please see an earlier post:http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=260293&SiteID=1

    If that still doesn't help, do let me know.

    Thanks,

    Vignesh



  • Jeff A Beck

    Just a guess, but check your InnerException and see if it says something about EventArgs not serializable.

    If so, then you are experiencing a similar problem to what alot of us here have already encountered and you will need to change your code to pass null as the sender parameter when raising the event.

    From my perspective, this is a bug in the WWF that needs to be addressed.

    If this is not the problem that you are having then ignore my rambling ;-), it's just that the only time I had this problem with raising an event 'into' the workflow that's what it turned out to be.

    -- /chris


  • JLucak

    Here is the full trace. There is nothing about 'correlation token properties' - at least nothing I have implemented (don't know what they are).

    Failed to locate ID: System.Workflow.Activities.EventDeliveryFailedException: Event "CalledCustomerPromisedPayment" on interface type "WorkflowLibrary.ICreditControl" for instance id "34eee293-e6b1-4185-aaf9-42c55acc016e" cannot be delivered. ---> System.InvalidOperationException: Event Queue operation failed with MessageQueueErrorCode QueueNotFound for queue 'Message Properties
    Interface Type:WorkflowLibrary.ICreditControl
    Method Name:CalledCustomerPromisedPayment
    CorrelationValues:
    '.
    at System.Workflow.Runtime.WorkflowQueuingService.GetQueue(IComparable queueID)
    at System.Workflow.Runtime.WorkflowQueuingService.EnqueueEvent(IComparable queueName, Object item)
    at System.Workflow.Runtime.WorkflowExecutor.EnqueueItem(IComparable queueName, Object item, IPendingWork pendingWork, Object workItem)
    at System.Workflow.Runtime.WorkflowInstance.EnqueueItem(IComparable queueName, Object item, IPendingWork pendingWork, Object workItem)
    at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)
    --- End of inner exception stack trace ---
    at System.Workflow.Activities.WorkflowMessageEventHandler.EventHandler(Object sender, ExternalDataEventArgs eventArgs)
    at WorkflowLibrary.CreditControlService.CalledDIRECT(Guid ID, DateTime d) in C:\Documents and Settings\Howard\Desktop\VisualStudio\Projects\WorkflowTest1 (2)\WorkflowLibrary\CreditControl.vb:line 92
    at CreditControlTasks.Called_Click(Object sender, EventArgs e) in C:\WebSites\WorkflowTest1\CreditControlTasks.aspx.vb:line 26



  • biloxibeachboy

    any luck for this problem. i also having the same problem Sad

  • Error: EventDeliveryFailedException ?