The * event is not handled during the * state for the * state machine

1,448 views
Skip to first unread message

Joe Ivans

unread,
Apr 4, 2018, 4:40:30 PM4/4/18
to masstransit-discuss
Hi,

I'm making a saga and microservices proof of concept for my team at work using C#, Automatonymous and MassTransit.RabbitMQ that's easy to use as an example.

Does anyone know what could cause this error to occur randomly: Automatonymous.UnhandledEventException

The error is perfectly clear to me but that implies the machine's not in the right state to handle this particular event even though it should have transitioned to that state beforehand but I guess it didn't.

It's kind of random when the exceptions occur and it doesn't happen for the same event every time. For me it takes anywhere from 1 to 10 minutes for the first error to show up in the orchestrator's _error queue.

I'm using InMemorySagaRepository and no other persistence except what RabbitMQ provides for the queueing.

As far as RabbitMQ, I only added a virtualhost called shipabox and then it looks like MassTransit takes care of the rest on startup.

Here's the project's files: https://github.com/joeivans/ShipABox

Here's a copy of one of the error message's headers:
message_id:8f390000-9d01-507b-9f08-08d59a5f64b7
correlation_id
:a00d854e-4bd3-4665-90fd-df5c09572add
delivery_mode
:2
headers
:
Content-Type: application/vnd.masstransit+json
MT
-Fault-ExceptionType: Automatonymous.UnhandledEventException
MT
-Fault-Message: The ClerkProvidedTrackingNumber event is not handled during the BoxInTruck state for the ShipmentSaga state machine
MT
-Fault-StackTrace: at Automatonymous.AutomatonymousStateMachine`1.DefaultUnhandledEventCallback(UnhandledEventContext`1 context)
at
Automatonymous.AutomatonymousStateMachine`1.UnhandledEvent(EventContext`1 context, State state)
at
Automatonymous.States.StateMachineState`1.<Automatonymous-State<TInstance>-Raise>d__28`1.MoveNext()
at
Automatonymous.AutomatonymousStateMachine`1.<Automatonymous-StateMachine<TInstance>-RaiseEvent>d__23`1.MoveNext()
at
Automatonymous.Pipeline.StateMachineSagaMessageFilter`2.<Send>d__5.MoveNext()
MT-Fault-Timestamp: 2018-04-04T19:08:04.5872405Z
MT-Host-Assembly: ShipABox.Orchestrator
MT-Host-AssemblyVersion: 1.0.0.0
MT-Host-FrameworkVersion: 4.0.30319.42000
MT-Host-MachineName: WORK
MT-Host-MassTransitVersion: 4.0.1.1390
MT-Host-OperatingSystemVersion: Microsoft Windows NT 6.2.9200.0
MT-Host-ProcessId: 19336
MT-Host-ProcessName: ShipABox.Orchestrator
MT-Reason: fault
publishId: 1
content_type:application/vnd.masstransit+json

Here's a copy of the error message's payload:
{
 
"messageId": "8f390000-9d01-507b-9f08-08d59a5f64b7",
 
"correlationId": "a00d854e-4bd3-4665-90fd-df5c09572add",
 
"conversationId": "8f390000-9d01-507b-3df5-08d59a5f64b4",
 
"initiatorId": "a00d854e-4bd3-4665-90fd-df5c09572add",
 
"sourceAddress": "rabbitmq://localhost/shipabox/shipabox.clerk.trackingnumberprovider",
 
"destinationAddress": "rabbitmq://localhost/shipabox/ShipABox.Common.Contracts.Events:IClerkProvidedTrackingNumberEvent",
 
"messageType": [
 
"urn:message:ShipABox.Common.Contracts.Events:IClerkProvidedTrackingNumberEvent"
 
],
 
"message": {
 
"customerName": "Destiney Beer",
 
"addressStreet": "681 Anastasia Station",
 
"addressCity": "Ankundington",
 
"addressState": "Iowa",
 
"addressZip": "57502",
 
"boxDimensionsX": 19.82,
 
"boxDimensionsY": 8.41,
 
"boxDimensionsZ": 8.58,
 
"boxWeight": 85.81,
 
"boxWeightUnit": "lbs",
 
"subTotal": 42.9,
 
"tax": 3.75,
 
"total": 46.65,
 
"timestampInvoiceCreated": "2018-04-04T12:08:04.4871694-07:00",
 
"paidInFull": true,
 
"timestampPaymentInitiated": "2018-04-04T12:08:04.4926723-07:00",
 
"trackingNumber": "pohpbs0w1dwaqbhdnygw1",
 
"carrierId": "programming",
 
"timestampTrackingCreated": "2018-04-04T12:08:04.4991778-07:00",
 
"timestampDeliveryExpected": "2018-04-06T00:00:00-07:00",
 
"correlationId": "a00d854e-4bd3-4665-90fd-df5c09572add"
 
},
 
"headers": {},
 
"host": {
 
"machineName": "WORK",
 
"processName": "ShipABox.Clerk.TrackingNumberProvider",
 
"processId": 17880,
 
"assembly": "ShipABox.Clerk.TrackingNumberProvider",
 
"assemblyVersion": "1.0.0.0",
 
"frameworkVersion": "4.0.30319.42000",
 
"massTransitVersion": "4.0.1.1390",
 
"operatingSystemVersion": "Microsoft Windows NT 6.2.9200.0"
 
}
}


Thanks for the help and for making these tools available! -Joe

Chris Patterson

unread,
Apr 5, 2018, 1:06:16 AM4/5/18
to masstrans...@googlegroups.com
Events may occur out of order, it's likely that you received the tracking number event after the box was already moved into the truck.

In this case, I'd accept that event in the subsequent states to allow the data to be captured without changing the state.

You could DuringAny() to allow those events to be handled in any state (other than Initial, which isn't included in the DuringAny() block).



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/1591360e-3a43-46e8-8a18-ed2486d13f9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joe Ivans

unread,
Apr 5, 2018, 1:59:07 PM4/5/18
to masstransit-discuss
Awesome. Thank you!
Reply all
Reply to author
Forward
0 new messages