The sample demonstrates how to use a file to describe the logical routing topology.
Make sure MSMQ is set up as described in the MSMQ Transport - NServiceBus Configuration section.
- Start the solution.
- The text
Press <enter> to send a messageshould be displayed in the Client's console window.
- Hit enter several times to send some messages.
- The Sales console display information about accepted orders in round-robin fashion.
- The Shipping endpoint displays information that orders were shipped.
- The Billing endpoint displays information that orders were billed.
This sample contains four projects. All these project make use of a shared routing file.
<endpoints> <endpoint name="Samples.FileBasedRouting.Sales"> <handles> <command type="PlaceOrder, Shared"/> </handles> </endpoint> <endpoint name="Samples.FileBasedRouting.Billing"> <handles> <event type="OrderAccepted, Shared"/> </handles> </endpoint> <endpoint name="Samples.FileBasedRouting.Shipping"> <handles> <events assembly="Shared"/> </handles> </endpoint> </endpoints>
For the purpose of the sample, the file is stored in the local file system. The routing mechanism based on the contents of the file is enabled by following code:
var transport = endpointConfiguration.UseTransport<LearningTransport>(); var routing = transport.Routing(); routing.UseFileBasedRouting(@"..\..\..\endpoints.xml");