Access to workflow queues from external processes RRS feed

  • Question

  • I'm having a hard time figuring out some things about the WorkflowQueuingService. What I'm trying to do is use queues in a custom activity to enqueue and dequeue messages being transferred between the workflow and a web service that is hosting the workflow. I know there are other ways to do this, such as using SendActivity and ReceiveActivity, but I think I have some good reasons to do things the way I am (I have 30 years of experience building network applications).

    There are two things that sort of baffle me. The first is that, even though I am starting the workflow runtime from within my web service, I can't seem to access the workflow queuing service. When I do a GetWorkflowService<WorkflowQueuingService> it returns null, even though if I start a workflow instance in that runtime the activities in that instance have access to the queuing service. I'm wondering if there is something I need to do to initialize the queuing service in the runtime so that it is accesible outside of the activities.

    Related to this, I don't understand why there is an EnqueueItem function in the workflow instance, but no DequeueItem. For example, I've seen how to respond to an OnIdle event from an activity, and in that I can get access to the queues to communicate with the activity from my web service. I can then enqueue an inbound message to the activity, but I can't dequeue an outbound message (although I can see it using GetWorkflowQueueData. I have to dequeue it from within the activity itself.

    I would think one of the more useful aspects of workflow queues would be to use them to manage asynchronous communications with external processes. I did figure out how to do this with MSMQ, but it's not clear that it is going to be persisted reliably with the rest of the workflow, and I'm concerned it may lead to inderterminate states occuring where things are out of sync between the workflow and the external process.

    Any suggestions? If it involves using multiple activities to perform one send/receive action, setting up proxy activities or processes, persisting things on my own, etc., I don't really want to hear about it. I'm trying to use workflow to simplify my life, not make it more complicated.
    Thursday, January 14, 2010 5:11 PM


  • The WorkflowQueueingService is used to queue data FROM the host TO the workflow activity. The host only gets access thru WorkflowInstance.GetWorkflowQueueData and WorkflowInstance.EnqueueItem.

    GetWorkflowQueueData returns WorkflowQueueInfo objects which identifies the events that the workflow is waiting for. EnqueueItem essentially raises those events.

    It sounds like what you want is to implement an ExternalDataDataExchangeService. You can find a sample at http://msdn.microsoft.com/en-us/library/ms742138.aspx.

    Monday, January 18, 2010 9:56 PM