State machine timing out

Nov 24, 2010 at 4:40 PM

Hello,

I have the following state machine workflow that has 4 states (Start, State1, State2, and State3) with transitions between then.  Each transition is a Receive activty.  They all correlate on the same Correlation Handle which is initialized by the first Receive call (State1).  Each Receive call accepts an integer message item and the correlation handle is set to correlate with that integer.  The State1 Receive activity is the only one that is set 'CanCreateInstance = true'.  The problem I'm having is that the workflow seems to time-out when I try to call it with an invalid transition.  For example it works fine if I call it in this order:

State1(123) -> State2(123) -> State3(123)

And it works fine if I try to call it with an integer that has not been initialiized yet.  It throws an exception immediately which is what I expect:

State1(123) -> State2(456)

But when I try to call it like this:

State1(123) -> State3(123)

It never responds and the Wcf call eventually times-out.  I would expect similar behavior as the second example above.  I would expect an immediate exception to be thrown because you can't transition from State1 to State3 without going to State2 first.

What am I missing?  Is this a bug in the state machine?

 

Here is the XAML for my state machine workflow:

 

<WorkflowService mc:Ignorable="sap"
                 ConfigurationName="Service1"
                 sap:VirtualizedContainerService.HintSize="644,666"
                 Name="Service1"
                 mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"
                 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel"
                 xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:mas="clr-namespace:Microsoft.Activities.Statements;assembly=Microsoft.Activities.StateMachine"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System"
                 xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
                 xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities"
                 xmlns:s="clr-namespace:System;assembly=mscorlib"
                 xmlns:s1="clr-namespace:System;assembly=System"
                 xmlns:s2="clr-namespace:System;assembly=System.Xml"
                 xmlns:s3="clr-namespace:System;assembly=System.Core"
                 xmlns:s4="clr-namespace:System;assembly=System.ServiceModel"
                 xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities"
                 xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities"
                 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
                 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System"
                 xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel"
                 xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core"
                 xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib"
                 xmlns:sd="clr-namespace:System.Data;assembly=System.Data"
                 xmlns:sl="clr-namespace:System.Linq;assembly=System.Core"
                 xmlns:ssa="clr-namespace:System.ServiceModel.Activities;assembly=System.ServiceModel.Activities"
                 xmlns:ssx="clr-namespace:System.ServiceModel.XamlIntegration;assembly=System.ServiceModel"
                 xmlns:st="clr-namespace:System.Text;assembly=mscorlib"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <mas:StateMachine InitialState="{x:Reference __ReferenceID7}"
                    sad:XamlDebuggerXmlReader.FileName="C:\Temp\DeclarativeServiceLibrary6\DeclarativeServiceLibrary6\Service1.xamlx"
                    sap:VirtualizedContainerService.HintSize="748,636"
                    mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">
    <sap:WorkflowViewStateService.ViewState>
      <scg3:Dictionary x:TypeArguments="x:String, x:Object">
        <x:Boolean x:Key="IsExpanded">False</x:Boolean>
        <x:Double x:Key="StateContainerWidth">733.5</x:Double>
        <x:Double x:Key="StateContainerHeight">600</x:Double>
        <av:PointCollection x:Key="ConnectorLocation">270,40 70.114,40 70.114,169.5</av:PointCollection>
      </scg3:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <mas:State x:Name="__ReferenceID6"
               DisplayName="State1">
      <mas:State.Transitions>
        <mas:Transition DisplayName="State2()"
                        sap:VirtualizedContainerService.HintSize="326,621">
          <mas:Transition.Trigger>
            <Receive x:Name="__ReferenceID0"
                     CorrelatesWith="[_handle]"
                     sap:VirtualizedContainerService.HintSize="300,150"
                     OperationName="State2">
              <Receive.CorrelatesOn>
                <XPathMessageQuery x:Key="key1">
                  <XPathMessageQuery.Namespaces>
                    <ssx:XPathMessageContextMarkup>
                      <x:String x:Key="xg0">http://schemas.microsoft.com/2003/10/Serialization/</x:String>
                    </ssx:XPathMessageContextMarkup>
                  </XPathMessageQuery.Namespaces>sm:body()/xg0:int
                </XPathMessageQuery>
              </Receive.CorrelatesOn>
              <Receive.CorrelationInitializers>
                <QueryCorrelationInitializer CorrelationHandle="[_handle]">
                  <XPathMessageQuery x:Key="key1">
                    <XPathMessageQuery.Namespaces>
                      <ssx:XPathMessageContextMarkup>
                        <x:String x:Key="xg0">http://schemas.microsoft.com/2003/10/Serialization/</x:String>
                      </ssx:XPathMessageContextMarkup>
                    </XPathMessageQuery.Namespaces>sm:body()/xg0:int
                  </XPathMessageQuery>
                </QueryCorrelationInitializer>
              </Receive.CorrelationInitializers>
              <ReceiveMessageContent>
                <p:OutArgument x:TypeArguments="x:Int32">[input]</p:OutArgument>
              </ReceiveMessageContent>
            </Receive>
          </mas:Transition.Trigger>
          <sap:WorkflowViewStateService.ViewState>
            <scg3:Dictionary x:TypeArguments="x:String, x:Object">
              <av:PointCollection x:Key="ConnectorLocation">317,200 347,200 347,139.5 432.038,139.5 432.038,169.5</av:PointCollection>
            </scg3:Dictionary>
          </sap:WorkflowViewStateService.ViewState>
          <mas:Transition.To>
            <mas:State x:Name="__ReferenceID2"
                       DisplayName="State2">
              <mas:State.Transitions>
                <mas:Transition DisplayName="State3()"
                                sap:VirtualizedContainerService.HintSize="326,621">
                  <mas:Transition.Trigger>
                    <Receive x:Name="__ReferenceID1"
                             CorrelatesWith="[_handle]"
                             sap:VirtualizedContainerService.HintSize="300,150"
                             OperationName="State3">
                      <Receive.CorrelatesOn>
                        <XPathMessageQuery x:Key="key1">
                          <XPathMessageQuery.Namespaces>
                            <ssx:XPathMessageContextMarkup>
                              <x:String x:Key="xg0">http://schemas.microsoft.com/2003/10/Serialization/</x:String>
                            </ssx:XPathMessageContextMarkup>
                          </XPathMessageQuery.Namespaces>sm:body()/xg0:int
                        </XPathMessageQuery>
                      </Receive.CorrelatesOn>
                      <ReceiveMessageContent>
                        <p:OutArgument x:TypeArguments="x:Int32">[input]</p:OutArgument>
                      </ReceiveMessageContent>
                    </Receive>
                  </mas:Transition.Trigger>
                  <sap:WorkflowViewStateService.ViewState>
                    <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                      <av:PointCollection x:Key="ConnectorLocation">527,200 557,200 557,139.5 660.114,139.5 660.114,169.5</av:PointCollection>
                    </scg3:Dictionary>
                  </sap:WorkflowViewStateService.ViewState>
                  <mas:Transition.To>
                    <mas:State x:Name="__ReferenceID3"
                               DisplayName="State3">
                      <mas:State.Transitions>
                        <mas:Transition DisplayName=""
                                        sap:VirtualizedContainerService.HintSize="326,459">
                          <mas:Transition.Trigger>
                            <p:Delay Duration="00:00:05"
                                     sap:VirtualizedContainerService.HintSize="300,150" />
                          </mas:Transition.Trigger>
                          <sap:WorkflowViewStateService.ViewState>
                            <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                              <av:PointCollection x:Key="ConnectorLocation">660.114,230.5 660.114,310 420,310</av:PointCollection>
                            </scg3:Dictionary>
                          </sap:WorkflowViewStateService.ViewState>
                          <mas:Transition.To>
                            <mas:State x:Name="__ReferenceID4"
                                       DisplayName="Final"
                                       IsFinal="True">
                              <sap:WorkflowViewStateService.ViewState>
                                <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                                  <av:Point x:Key="ShapeLocation">360,272.5</av:Point>
                                  <av:Size x:Key="ShapeSize">60,75</av:Size>
                                </scg3:Dictionary>
                              </sap:WorkflowViewStateService.ViewState>
                            </mas:State>
                          </mas:Transition.To>
                        </mas:Transition>
                      </mas:State.Transitions>
                      <sap:WorkflowViewStateService.ViewState>
                        <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                          <av:Point x:Key="ShapeLocation">603,169.5</av:Point>
                          <av:Size x:Key="ShapeSize">114,61</av:Size>
                        </scg3:Dictionary>
                      </sap:WorkflowViewStateService.ViewState>
                    </mas:State>
                  </mas:Transition.To>
                  <mas:Transition.Action>
                    <p:Sequence sap:VirtualizedContainerService.HintSize="300,312">
                      <sap:WorkflowViewStateService.ViewState>
                        <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                          <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                        </scg3:Dictionary>
                      </sap:WorkflowViewStateService.ViewState>
                      <p:Assign sap:VirtualizedContainerService.HintSize="255,58">
                        <p:Assign.To>
                          <p:OutArgument x:TypeArguments="x:String">[result]</p:OutArgument>
                        </p:Assign.To>
                        <p:Assign.Value>
                          <p:InArgument x:TypeArguments="x:String">["State2 to State3: " &amp; input]</p:InArgument>
                        </p:Assign.Value>
                      </p:Assign>
                      <SendReply Request="{x:Reference __ReferenceID1}"
                                 DisplayName="SendReplyToReceive"
                                 sap:VirtualizedContainerService.HintSize="255,90">
                        <SendMessageContent>
                          <p:InArgument x:TypeArguments="x:String">[result]</p:InArgument>
                        </SendMessageContent>
                      </SendReply>
                    </p:Sequence>
                  </mas:Transition.Action>
                </mas:Transition>
              </mas:State.Transitions>
              <sap:WorkflowViewStateService.ViewState>
                <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                  <av:Point x:Key="ShapeLocation">413,169.5</av:Point>
                  <av:Size x:Key="ShapeSize">114,61</av:Size>
                </scg3:Dictionary>
              </sap:WorkflowViewStateService.ViewState>
            </mas:State>
          </mas:Transition.To>
          <mas:Transition.Action>
            <p:Sequence sap:VirtualizedContainerService.HintSize="300,312">
              <sap:WorkflowViewStateService.ViewState>
                <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                  <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                </scg3:Dictionary>
              </sap:WorkflowViewStateService.ViewState>
              <p:Assign sap:VirtualizedContainerService.HintSize="255,58">
                <p:Assign.To>
                  <p:OutArgument x:TypeArguments="x:String">[result]</p:OutArgument>
                </p:Assign.To>
                <p:Assign.Value>
                  <p:InArgument x:TypeArguments="x:String">["State1 to State2: " &amp; input]</p:InArgument>
                </p:Assign.Value>
              </p:Assign>
              <SendReply Request="{x:Reference __ReferenceID0}"
                         DisplayName="SendReplyToReceive"
                         sap:VirtualizedContainerService.HintSize="255,90">
                <SendMessageContent>
                  <p:InArgument x:TypeArguments="x:String">[result]</p:InArgument>
                </SendMessageContent>
              </SendReply>
            </p:Sequence>
          </mas:Transition.Action>
        </mas:Transition>
      </mas:State.Transitions>
      <sap:WorkflowViewStateService.ViewState>
        <scg3:Dictionary x:TypeArguments="x:String, x:Object">
          <av:Point x:Key="ShapeLocation">203,169.5</av:Point>
          <av:Size x:Key="ShapeSize">114,61</av:Size>
        </scg3:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
    </mas:State>
    <x:Reference>__ReferenceID2</x:Reference>
    <x:Reference>__ReferenceID3</x:Reference>
    <x:Reference>__ReferenceID4</x:Reference>
    <mas:State x:Name="__ReferenceID7"
               DisplayName="Start">
      <mas:State.Transitions>
        <mas:Transition DisplayName="State1()"
                        sap:VirtualizedContainerService.HintSize="326,621">
          <mas:Transition.Trigger>
            <Receive x:Name="__ReferenceID5"
                     CanCreateInstance="True"
                     CorrelatesWith="[_handle]"
                     sap:VirtualizedContainerService.HintSize="300,150"
                     OperationName="State1">
              <Receive.CorrelatesOn>
                <XPathMessageQuery x:Key="key1">
                  <XPathMessageQuery.Namespaces>
                    <ssx:XPathMessageContextMarkup>
                      <x:String x:Key="xg0">http://schemas.microsoft.com/2003/10/Serialization/</x:String>
                    </ssx:XPathMessageContextMarkup>
                  </XPathMessageQuery.Namespaces>sm:body()/xg0:int
                </XPathMessageQuery>
              </Receive.CorrelatesOn>
              <ReceiveMessageContent>
                <p:OutArgument x:TypeArguments="x:Int32">[input]</p:OutArgument>
              </ReceiveMessageContent>
            </Receive>
          </mas:Transition.Trigger>
          <sap:WorkflowViewStateService.ViewState>
            <scg3:Dictionary x:TypeArguments="x:String, x:Object">
              <av:PointCollection x:Key="ConnectorLocation">127,200 157,200 157,139.5 260.114,139.5 260.114,169.5</av:PointCollection>
            </scg3:Dictionary>
          </sap:WorkflowViewStateService.ViewState>
          <mas:Transition.To>
            <x:Reference>__ReferenceID6</x:Reference>
          </mas:Transition.To>
          <mas:Transition.Action>
            <p:Sequence sap:VirtualizedContainerService.HintSize="300,312">
              <sap:WorkflowViewStateService.ViewState>
                <scg3:Dictionary x:TypeArguments="x:String, x:Object">
                  <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                </scg3:Dictionary>
              </sap:WorkflowViewStateService.ViewState>
              <p:Assign sap:VirtualizedContainerService.HintSize="255,58">
                <p:Assign.To>
                  <p:OutArgument x:TypeArguments="x:String">[result]</p:OutArgument>
                </p:Assign.To>
                <p:Assign.Value>
                  <p:InArgument x:TypeArguments="x:String">["Start to State1: " &amp; input]</p:InArgument>
                </p:Assign.Value>
              </p:Assign>
              <SendReply Request="{x:Reference __ReferenceID5}"
                         DisplayName="SendReplyToReceive"
                         sap:VirtualizedContainerService.HintSize="255,90">
                <SendMessageContent>
                  <p:InArgument x:TypeArguments="x:String">[result]</p:InArgument>
                </SendMessageContent>
              </SendReply>
            </p:Sequence>
          </mas:Transition.Action>
        </mas:Transition>
      </mas:State.Transitions>
      <sap:WorkflowViewStateService.ViewState>
        <scg3:Dictionary x:TypeArguments="x:String, x:Object">
          <av:Point x:Key="ShapeLocation">13,169.5</av:Point>
          <av:Size x:Key="ShapeSize">114,61</av:Size>
        </scg3:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
    </mas:State>
    <mas:StateMachine.Variables>
      <p:Variable x:TypeArguments="CorrelationHandle"
                  Name="_handle" />
      <p:Variable x:TypeArguments="x:String"
                  Name="result" />
      <p:Variable x:TypeArguments="x:Int32"
                  Name="input" />
    </mas:StateMachine.Variables>
  </mas:StateMachine>
</WorkflowService>