Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Modernization
Samples

Connection Settings

Component: IBM MQ Transport
NuGet Package: NServiceBus.Transport.IBMMQ 1.x
Target Version: NServiceBus 10.x

Basic connection

The transport connects to an IBM MQ queue manager using a host, port, and SVRCONN channel:

var transport = new IBMMQTransport
{
    Host = "mq-server.example.com",
    Port = 1414,
    Channel = "DEV.APP.SVRCONN",
    QueueManagerName = "QM1"
};

Defaults

SettingDefault
Hostlocalhost
Port1414
ChannelDEV.ADMIN.SVRCONN
QueueManagerNameEmpty (local default queue manager named QM1)

Authentication

User credentials can be provided to authenticate with the queue manager:

var transport = new IBMMQTransport
{
    Host = "mq-server.example.com",
    QueueManagerName = "QM1",
    User = "app",
    Password = "passw0rd"
};

Application name

The application name appears in IBM MQ monitoring tools and is useful for identifying connections:

var transport = new IBMMQTransport
{
    // ... connection settings ...
    ApplicationName = "OrderService"
};

If not specified, the application name defaults to the entry assembly name.

High availability

For high availability scenarios with multi-instance queue managers, provide a connection name list instead of a single host and port:

var transport = new IBMMQTransport
{
    QueueManagerName = "QM1",
    Channel = "APP.SVRCONN",
    Connections = { "mqhost1(1414)", "mqhost2(1414)" }
};

When Connections is specified, the Host and Port properties are ignored. The client will attempt each connection in order, connecting to the first available queue manager.

SSL/TLS

To enable encrypted communication, configure the SSL key repository and cipher specification. The cipher must match the SSLCIPH attribute on the SVRCONN channel.

var transport = new IBMMQTransport
{
    Host = "mq-server.example.com",
    QueueManagerName = "QM1",
    SslKeyRepository = "*SYSTEM",
    CipherSpec = "TLS_RSA_WITH_AES_256_CBC_SHA256"
};

Key repository options

ValueDescription
*SYSTEMWindows system certificate store
*USERWindows user certificate store
File pathPath to a key database file (without extension), e.g., /var/mqm/ssl/key

Peer name verification

Verify the queue manager's certificate distinguished name for additional security:

var transport = new IBMMQTransport
{
    // ... connection settings ...
    SslKeyRepository = "*SYSTEM",
    CipherSpec = "TLS_RSA_WITH_AES_256_CBC_SHA256",
    SslPeerName = "CN=MQSERVER01,O=MyCompany,C=US"
};

Topic naming

Topics are named using a configurable TopicNaming strategy. The default uses a prefix of DEV and the fully qualified type name.

Custom topic prefix

To change the prefix:

var transport = new IBMMQTransport
{
    // ... connection settings ...
    TopicNaming = new TopicNaming("PROD")
};

Custom topic naming strategy

IBM MQ topic names are limited to 48 characters. If event type names are long, subclass TopicNaming to implement a shortening strategy:

public sealed class ShortTopicNaming() : TopicNaming("APP")
{
    public override string GenerateTopicName(Type eventType)
    {
        return $"APP.{eventType.Name}".ToUpperInvariant();
    }
}
var transport = new IBMMQTransport
{
    // ... connection settings ...
    TopicNaming = new ShortTopicNaming()
};

Resource name sanitization

IBM MQ queue and topic names are limited to 48 characters and allow only A-Z, a-z, 0-9, ., and _. If endpoint names contain invalid characters or are too long, you need to configure a sanitizer:

var transport = new IBMMQTransport
{
    // ... connection settings ...
    ResourceNameSanitizer = name =>
    {
        var sanitized = name.Replace("-", ".").Replace("/", ".");
        return sanitized.Length > 48 ? sanitized[..48] : sanitized;
    }
};

Circuit breaker

If the transport cannot communicate with the queue manager for a sustained period, it triggers a critical error. The default timeout is 2 minutes:

var transport = new IBMMQTransport
{
    // ... connection settings ...
    TimeToWaitBeforeTriggeringCircuitBreaker = TimeSpan.FromMinutes(5)
};
SettingDefault
TimeToWaitBeforeTriggeringCircuitBreaker2 minutes

Message processing settings

Polling interval

The wait interval controls how long each poll waits for a message before returning:

var transport = new IBMMQTransport
{
    // ... connection settings ...
    MessageWaitInterval = TimeSpan.FromMilliseconds(2000)
};
SettingDefaultRange
MessageWaitInterval5000 ms100–30,000 ms

Character set

The Coded Character Set Identifier (CCSID) used for message text encoding. The default is UTF-8 (1208), which is recommended for most scenarios.

var transport = new IBMMQTransport
{
    // ... connection settings ...
    CharacterSet = 1208 // UTF-8 (default)
};