Skip to content

Full Application Configuration File

This configuration is the default application configuration file based version. Some components that you may replace could very well have their own configuration stores.

To start off add the Shuttle.Esb.ServiceBusSection configuration class from the Shuttle.Esb assembly.

<configuration>
  <configSections>
    <section name='serviceBus' type="Shuttle.Esb.ServiceBusSection, Shuttle.Esb"/>
  </configSections>

It is also possible to group the Shuttle configuration in a shuttle group:

<configuration>
    <configSections>
        <sectionGroup name="shuttle">
            <section name='serviceBus' type="Shuttle.Esb.ServiceBusSection, Shuttle.Esb"/>
        </sectionGroup>
    </configSections>

The most pertinent bit is the serviceBus tag.

  <serviceBus
    cacheIdentity="true"  
    createQueues="true"  
    removeMessagesNotHandled="false"
    removeCorruptMessages="false"
    compressionAlgorithm=""
    encryptionAlgorithm="">
AttributeDefaultDescription
registerHandlerstrueWill call the RegisterHandlers method on the IMessageHandlerFactory implementation if set to true.
cacheIdentitytrueDetermines whether or not to re-use the identity returned by the IIdentityProvider.
createQueuestrueThe endpoint will attempt to create all local queues (inbox, outbox, control inbox)
removeMessagesNotHandledfalseIndicates whether messages received on the endpoint that have no message handler should simply be removed (ignored). If this attribute is true the message will simply be acknowledged; else the message will immmediately be placed in the error queue. The default changed from true to false in v7.0.1.
removeCorruptMessagesfalseA message is corrupt when the TransportMessage retrieved from the queue cannot be deserialized. If false (default) the service bus processed will be killed. If true the messae will be Acknowledged with no processing.
encryptionAlgorithmempty (no encryption)The name of the encryption algorithm to use when sending messages. Out-of-the-box there is a Triple DES implementation (class TripleDesEncryptionAlgorithm and name '3DES').

The IIdentityProvider implementation is responsible for honouring the cacheIdentity attribute.

Use the queueFactories tag to configure how you would like to locate queue factories. By default the current AppDomain is scanned for implementations of IQueueFactory along with all assemblies in the base directory (recursively). These queue factories have to have a parameterless constructor in order to be instantiated.

    <queueFactories scan="true|false">
        <add type="Shuttle.Esb.Msmq.MsmqQueueFactory, Shuttle.Esb.Msmq" />
        <add type="Shuttle.Esb.RabbitMQ.RabbitMQQueueFactory, Shuttle.Esb.RabbitMQ" />
        <add type="Shuttle.Esb.SqlServer.SqlQueueFactory, Shuttle.Esb.SqlServer" />
    </queueFactories>

The messageRoutes tag defines the routing for message that are sent using the IServiceBus.Send method. You will notice that the structure is the same as the forwardingRoutes tag.

    <messageRoutes>
      <messageRoute uri="msmq://./inbox">
        <add specification="StartsWith" value="Shuttle.Messages1" />
        <add specification="StartsWith" value="Shuttle.Messages2" />
      </messageRoute>
      <messageRoute uri="sql://./inbox">
        <add specification="TypeList" value="DoSomethingCommand" />
      </messageRoute>
    </messageRoutes>

The inbox should be specified if the endpoint has message handlers that need to process incoming messages.

    <inbox
      workQueueUri="msmq://./inbox-work"
      deferredQueueUri="msmq://./inbox-work-deferred"
      errorQueueUri="msmq://./shuttle-error"
      threadCount="25"
      durationToSleepWhenIdle="250ms,500ms,1s,5s"
      durationToIgnoreOnFailure="30m,1h"
      maximumFailureCount="25" 
      distribute="true|false" 
      distributeSendCount="5" />
AttributeDefaultDescription
threadCount5The number of worker threads that will service the inbox work queue. The deferred queue will always be serviced by only 1 thread.
durationToSleepWhenIdle250ms,500ms,1s,5sUses the StringDurationArrayConverter to convert to an array of TimeSpan instances. Specify ms (milliseconds), s (seconds), m (minutes), h (hours), d (days) * (times) count.
durationToIgnoreOnFailure5m,30m,60mUses the StringDurationArrayConverter to convert to an array of TimeSpan instances. Specify ms (milliseconds), s (seconds), m (minutes), h (hours), d (days) * (times) count.
maximumFailureCount5The maximum number of failures that are retried before the message is moved to the error queue.
distributefalseIf true the endpoint will act as only a distributor. If false the endpoint will distribute messages if a worker is available; else process the message itself.
distributeSendCount5The number of messages to send to the worker per available thread message received. If less than 1 the default will be used.

For some queueing technologies the outbox may not be required. Msmq, for instance, create its own outgoing queues. However, it should be used in scenarios where you need a store-and-forward mechanism for sending messages when the underlying infrastructure does not provide this such as with a SqlServer table-based queue or maybe even the file system. RabbitMQ will also need an outbox since the destination broker may not be available and it does not have the concept of outgoing queues.

    <outbox
      workQueueUri="msmq://./outbox-work"
      errorQueueUri="msmq://./shuttle-error"
      durationToSleepWhenIdle="250ms,10s,30s"
      durationToIgnoreOnFailure="30m,1h"
      maximumFailureCount="25"
      threadCount="5" />
AttributeDefaultDescription
threadCount1The number of worker threads that will service the outbox work queue.
durationToSleepWhenIdle250ms,500ms,1s,5sUses the StringDurationArrayConverter to convert to an array of TimeSpan instances. Specify ms (milliseconds), s (seconds), m (minutes), h (hours), d (days) * (times) count.
durationToIgnoreOnFailure5m,30m,60mUses the StringDurationArrayConverter to convert to an array of TimeSpan instances. Specify ms (milliseconds), s (seconds), m (minutes), h (hours), d (days) * (times) count.
maximumFailureCount5The maximum number of failures that are retried before the message is moved to the error queue.

When the endpoint is not a physical endpoint but rather a worker use the worker tag to specify the relevant configuration.

    <worker
      distributorControlWorkQueueUri="msmq://./control-inbox-work"
      threadAvailableNotificationIntervalSeconds="5" />
AttributeDefaultDescription
distributorControlWorkQueueUrin/aThe control work queue uri of the distributor endpoint that this endpoint can handle messages for.
threadAvailableNotificationIntervalSeconds15The number of seconds to wait on an idle thread before notifying the distributor of availability again

Since a worker sends thread availability to the physical distribution master the distributor needs to have a special inbox called the control inbox that is used for these notifications.

    <control
      workQueueUri="control-inbox-work"
      errorQueueUri="msmq://./shuttle-error"
      threadCount="25"
      durationToSleepWhenIdle="250ms,10s,30s"
      durationToIgnoreOnFailure="30m,1h"
      maximumFailureCount="25" />
AttributeDefaultDescription
threadCount1The number of worker thread that will service the control work queue.
durationToSleepWhenIdle250ms,500ms,1s,5sUses the StringDurationArrayConverter to convert to an array of TimeSpan instances. Specify ms (milliseconds), s (seconds), m (minutes), h (hours), d (days) * (times) count.
durationToIgnoreOnFailure5m,30m,60mUses the StringDurationArrayConverter to convert to an array of TimeSpan instances. Specify ms (milliseconds), s (seconds), m (minutes), h (hours), d (days) * (times) count.
maximumFailureCount5The maximum number of failures that are retried before the message is moved to the error queue.

Use the modules tag to configure modules that can be loaded at runtime. These modules have to have a parameterless constructor in order to be instantiated; else add them programmatically if you need to specify parameters.

    <modules>
        <add type="Shuttle.Esb.Modules.ActiveTimeRangeModule, Shuttle.Esb.Modules" />
    </modules>

If you need to make use of the DefaultUriResolver you can specify the mappings as follows:

    <uriResolver>
        <add name="resolver://host/queue-1" uri="msmq://./inbox-work-queue" />
        <add name="resolver://host/queue-2" uri="rabbitmq://user:password@the-server/inbox-work-queue" />
    </uriResolver>

Finally just close the relevant tags.

  </serviceBus>
</configuration>

You may wish to consider using the TransactionScope section to configure transactional behaviour for your endpoint.

Full Application Configuration File has loaded