Configuring MSMQ for use with ServiceControl

Component: MSMQ Transport
NuGet Package NServiceBus (5.x)
Standard support for version 5.x of NServiceBus has expired. For more information see our Support Policy.

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
  • Amazon SQS

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:

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;
    }
}
busConfiguration.CustomConfigurationSource(new ConfigurationSource());

For more information about how to configure the audit queue refer to the Configuring auditing documentation.

Related Articles

  • Configure error handling
    Error handler configuration when messages are forwarded to the error queue after failing a certain number of times.

Last modified