Controlling Message Throughput

Initial Configuration

The initial message Throughput of an endpoint can be configured in both code and app.config.

Via Code

By overriding app.config settings.

public class ProvideConfiguration :
    IProvideConfiguration<MsmqTransportConfig>
{
    public MsmqTransportConfig GetConfiguration()
    {
        return new MsmqTransportConfig
        {
            NumberOfWorkerThreads = 5
        };
    }
}
public class ProvideConfiguration :
    IProvideConfiguration<TransportConfig>
{
    public TransportConfig GetConfiguration()
    {
        return new TransportConfig
        {
            MaximumConcurrencyLevel = 5,
            MaximumMessageThroughputPerSecond = 10
        };
    }
}

Via app.config

By using raw xml.

<configSections>
  <section name="MsmqTransportConfig"
           type="NServiceBus.Config.TransportConfig, NServiceBus.Core"/>
</configSections>
<MsmqTransportConfig NumberOfWorkerThreads="5" />
<configSections>
  <section name="TransportConfig"
           type="NServiceBus.Config.TransportConfig, NServiceBus.Core"/>
</configSections>
<TransportConfig NumberOfWorkerThreads="5"
                 MaximumMessageThroughputPerSecond="10"/>
<configSections>
  <section name="TransportConfig"
           type="NServiceBus.Config.TransportConfig, NServiceBus.Core"/>
</configSections>
<TransportConfig MaximumConcurrencyLevel="5"
                 MaximumMessageThroughputPerSecond="10"/>

Changing Throughput at run time

//bus is an instance of NServiceBus.Unicast.UnicastBus
bus.Transport.ChangeMaximumMessageThroughputPerSecond(10);
bus.Transport.ChangeMaximumConcurrencyLevel(5);

Reading Throughput at run time

//bus is an instance of NServiceBus.Unicast.UnicastBus
int messageThroughputPerSecond = bus.Transport.MaximumMessageThroughputPerSecond;
int maximumConcurrencyLevel = bus.Transport.MaximumConcurrencyLevel;

Related Articles



Last modified 2015-08-30 07:37:57Z