MSMQ Workflow Activities, V1

I've just uploaded a set of sample Windows Workflow Foundation activities for Microsoft Message Queue in the Winterdom.Workflow.Activities.Msmq assembly.

The MsmqSendActivity allows you to send a .NET object as an MSMQ message by just binding the activity to one of your workflow's properties and selecting the appropriate formatter (XmlMessageFormatter or BinaryFormatter). If the queue is transactional, you can put the activity inside a TransactionalScope activity.

The MsmqReceiveActivity allows you to receive an MSMQ message into a typed .NET object; the activity will do the deserialization based on the selected formatter. The activity can also be used inside an EventDrivenActivity so you can use it inside a Listen shape or in a StateMachine workflow to trigger state changes.

The samples include the following features:

  • Bindable properties, through both direct and attached dependency properties.
  • Design-Time support: each activity has a customized appearance. The MsmqReceiveActivity also shows the use of a custom activity designer to synthetize a property at design-time that supports binding.
  • Validation support: Both activities contain sample validators to ensure the required properties are configured correctly.

Here's a sample of how they could be used in XOML:

      xmlns:ns0="clr-namespace:Winterdom.Workflow.Activities.Msmq;Assembly=Winterdom.Workflow.Activities.Msmq, Version=, Culture=neutral, PublicKeyToken=null"
    <TransactionScopeActivity x:Name="SendScope">
            <WorkflowTransactionOptions TimeoutDuration="00:00:30"
            IsolationLevel="Serializable" />
            Queue="{ActivityBind SampleWorkflow2,Path=QUEUE}"
            Label="{ActivityBind SampleWorkflow2,Path=_labelToSend}"
                <ActivityBind Name="SampleWorkflow2" Path="_customerToSend" />
         Queue="{ActivityBind SampleWorkflow2,Path=QUEUE}"
         ns0:MsmqReceiveActivity.Label="{ActivityBind SampleWorkflow2,Path=_labelReceived}"
         MessageType="{x:Type TestApp.Customer}"
            <ActivityBind Name="SampleWorkflow2" Path="_customerReceived" />

If you plan to use the MsmqReceiveActivity, you'll need to configure the MsmqListenerService service into the WorkflowRuntime, like this:

WorkflowRuntime workflowRuntime = new WorkflowRuntime("ConsoleApplication");
workflowRuntime.AddService(new MsmqListenerService());

Update: The sample activities can be downloaded from here.

I hope to improve them and add new functionality (if I can) to them, so if you have any comments/bugs/features, do let me know! One feature I would definitely like to implement is correlation support, but as of now I'm not entirely sure what the best approach for that might be.

1 comment

  1. I am new to WWF. I want to make a Windows application which supports me to serialize my workflow as I make my workflow jump from one machine to other. I mean, activity "Create Order" should be done in Machine A and "Approve Order" should be in Machine B. I tried serializing my workflow through SQL Server but how to take that to another machine through MSMQ? Also which workflow should I use? Sequential or event driven i.e. State Machine? As my ultimate aim is to get the workflow understand the last status of the client application when it starts the manager or server application.
    Please let me know any example or link that can help.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>