Configuring MSMQ for use with ServiceControl

Component: MSMQ Transport
NuGet Package NServiceBus (6.x)

ServiceControl reads messages from the input queue specified in the ServiceControl instance transport configuration. Monitored endpoints send appropriate messages, e.g. error or heartbeats, to the configured queues. ServiceControl ingests those messages in order to extract required information and saves messages in internal storage.

Depending on the selected transport and the deployment scenario, the production endpoints might require additional configuration for ServiceControl. Currently only MSMQ transport requires it.

The following transports don't need any additional configuration for remote queues:

  • SQL Server
  • RabbitMQ
  • Azure Storage Queues
  • Azure Service Bus

See Configure error handling for examples.

Remote MSMQ queues

If ServiceControl is installed on a different machine than endpoints using MSMQ Transport, then endpoints must be configured to send error and audit messages to a remote queue:

endpointConfiguration.SendFailedMessagesTo("targetErrorQueue@machinename");
class ProvideConfiguration : IProvideConfiguration<MessageForwardingInCaseOfFaultConfig>
{
    public MessageForwardingInCaseOfFaultConfig GetConfiguration()
    {
        return new MessageForwardingInCaseOfFaultConfig
        {
            ErrorQueue = "error@machinename"
        };
    }
}
public class ConfigurationSource : IConfigurationSource
{
    public T GetConfiguration<T>() where T : class, new()
    {
        if (typeof(T) == typeof(MessageForwardingInCaseOfFaultConfig))
        {
            var config = new MessageForwardingInCaseOfFaultConfig
            {
                ErrorQueue = "error@machinename"
            };

            return config as T;
        }

        // Respect app.config for other sections not defined in this method
        return System.Configuration.ConfigurationManager.GetSection(typeof(T).Name) as T;
    }
}
endpointConfiguration.CustomConfigurationSource(new ConfigurationSource());

Related Articles

  • Configure error handling
    Messages that failed a certain number of times will be forwarded to the error queue. This page shows how to configure error handling.

Last modified