Mar 012013
 

So if you are creating itineraries, order and you need to stick an orchestration in your itinerary, there are two orchestrations that come out of the box.

AWESOME!

image

 

However, if you are like me, you have found the documentation a little lacking, especially regarding these two orchestrations.

Looking at our previous blog entry about how to look at the shapes in an orchestration, I will describe what is going on with these two orchestrations.

Microsoft.Practices.ESB.Services.Routing
Receive Msg

Gets the message from the message box called InboundMessage

Get Current Itinerary

Retrieves the current Itinerary, Itinerary Step, logs ServiceName and ServiceType to the Trace.

Retrieve Resolvers

Retrieves the resolvers associated to the itinerary at this step, and logs to the trace the number of resolvers at this step

Resolvers Returned?

Checks to ensure that there are resolvers present (resolvers.Count > 0)

Loop through Resolvers

resolvers.MoveNext()

Resolve

Extract out of the resolvers, the current resolver, write to the trace, fill the resolverDictionary the items contained in the current resolver, log all of the items that are specified in the static resolver, set the transportLocation and transportType (internal strings)

Transport Info Returned

Ensured that the two strings have a length greater than 1

Construct Delivery Message/Set Delivery Message

Creates a new message from the InboundMessage called DeliveryMessage, sets the endpoint of the DeliveryMessage, sets the DeliveryPort’s address to the transportLocation and the deliveryPort’s transport type to transportType

Send Delivery

Sends the message off to the address

Catch Delivery Exception

Creates a fault message, sets the fault code to 2444, logs that An error occurred attempting to deliver message., sets the severity to critical and sends the message on

Catch Exception

Same thing except sets the fault code to 2555

and continues the looping through the rest of the resolvers

Advance Itinerary/Construct Outbound Message/Set Advance Itinerary

Creates a new message called OutboundMessage from the InboundMessage, advances the OutboundMessage itinerary, writes it, logs the ServiceName, SeriviceState, and ServiceType.

Catch Exception

If it throws an exception it logs it as 2555 and logs that there was an Exception while attempting to Advance Itinerary

More Itinerary Steps

Checks to see if the state is complete ( itineraryStep.ItineraryStep.State != Microsoft.Practices.ESB.Itinerary.State.Complete )

Send Message

Sends the OutboundMessage back to the bus

Construct Post Itinerary Fault Message

Logs 2777 with the following error message ‘Unable to persist routed message, are there subscribers for it?’

Catch Routing Resolution Exceptions

for some catastrophic error. a fault message is created with error 2111 with the error Exception while attempting to work with Itinerary Step

Use case

If you need to take your message off of the bus and send it out (Scatter pattern), this is the orchestration to do it.

 

 

Microsoft.Practices.ESB.Services.Transform
Receive Message

Receives InboundMessage from the bus

Get Current Itinerary

Retrieves the current Itinerary, Itinerary Step, logs ServiceName and ServiceType to the Trace.

Retrieve Resolvers

Retrieves the resolvers associated to the itinerary at this step, and logs to the trace the number of resolvers at this step

Resolvers Returned?

Checks to ensure that there are resolvers present (resolvers.Count > 0)

Resolve

Gets the current resolver, takes the items from the static resolver and adds it to the dictionary, logs it to the trace, and sets the transformType

Map Name Returned?

transformType.Lenth > 0

Construct Map Resolution Fault Message

Sets fault code to 1111 and logs Exception while attempting to determine map type, creates fault message and send it off

Construct Outbound Message/Construct Outbound Message

Executes the transform and advances the itinerary and drops the OutboundMessage off to the bus

Set Mp Exception Fault Message (sic)

Sets fault code to 1444 and logs Unable to retrieve the the Type for map type: the map

Set Map Execution Fault Message

Sets fault code to 1222 and logs Exception while attempting to apply map: the map

Use Case

You want to execute a map on the bus, you can add this service, specify the map in the resolver, and the map will be transformed and placed back on the bus.

(A close friend asked me if there was a way that multiple maps can be executed in a row in the ESB. This is a perfect service to do just that. Just remember, that only the first resolver will be invoked (any others will be ignored), so if you need multiple maps executed, you need to add multiple services chained together each with one resolver and you can incrementally map the data.)