Path: redb-route/redb.Route.IbmMq/IbmMqConnectionFactory.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.IbmMq/IbmMqConnectionFactory.cs ---- using System.Collections; using IBM.WMQ; using redb.Route.Core; namespace redb.Route.IbmMq; /// /// IBM MQ connection factory configuration. Standalone POCO — register in DI or reference by name. /// /// Encapsulates all connection properties: /// host/port/channel, authentication, SSL/TLS, and tuning. /// /// public sealed class IbmMqConnectionFactory { // ── Connection coordinates ── /// Queue manager hostname. Comma-separated for multi-instance failover. (default: localhost) public string Host { get; set; } = "localhost"; /// MQ listener port. (default: 1414) public int Port { get; set; } = 1414; /// Server-connection channel. (default: DEV.APP.SVRCONN) public string Channel { get; set; } = "DEV.APP.SVRCONN"; /// Queue manager name. public string QueueManager { get; set; } = "QM1"; /// Authentication user. public string? User { get; set; } /// Authentication password. [Sensitive] public string? Password { get; set; } /// Client name for connection tracking. public string? ClientName { get; set; } // ── Transport ── /// Transport type: client (TCP), bindings (local), or managed. (default: managed client) public string TransportType { get; set; } = MQC.TRANSPORT_MQSERIES_MANAGED; // ── SSL/TLS ── /// SSL CipherSpec (e.g. TLS_RSA_WITH_AES_256_CBC_SHA256). public string? SslCipherSpec { get; set; } /// SSL certificate label in keystore. public string? SslCertLabel { get; set; } /// Distinguished Name pattern for peer validation. public string? SslPeerName { get; set; } /// Path to key repository (.kdb file, without extension). public string? SslKeyRepository { get; set; } /// Bytes before SSL secret key renegotiation. 0 = disabled. public int SslKeyResetCount { get; set; } // ── Request-reply ── /// /// Model queue of the temporary reply queue a request-reply producer opens when no replyToQueue is set; IBM /// MQ's TEMPMODEL (temporaryModel on its JMS connection factory, XMSC.WMQ_TEMPORARY_MODEL in XMS). /// The connecting user needs display, get, put and inquire on it. (default: SYSTEM.DEFAULT.MODEL.QUEUE) /// public string TemporaryModel { get; set; } = DefaultTemporaryModel; /// IBM MQ's default model queue, the default of . public const string DefaultTemporaryModel = "SYSTEM.DEFAULT.MODEL.QUEUE"; // ── Tuning ── /// CCSID for the connection. (default: 1208 = UTF-8) public int CCSID { get; set; } = 1208; /// /// Builds a of MQ connection properties suitable for /// constructor. /// public Hashtable BuildConnectionProperties() { var props = new Hashtable { { MQC.TRANSPORT_PROPERTY, TransportType }, { MQC.HOST_NAME_PROPERTY, Host }, { MQC.PORT_PROPERTY, Port }, { MQC.CHANNEL_PROPERTY, Channel }, { MQC.CCSID_PROPERTY, CCSID }, }; if (!string.IsNullOrEmpty(User)) props[MQC.USER_ID_PROPERTY] = User; if (!string.IsNullOrEmpty(Password)) props[MQC.PASSWORD_PROPERTY] = Password; if (!string.IsNullOrEmpty(ClientName)) props[MQC.APPNAME_PROPERTY] = ClientName; // SSL/TLS if (!string.IsNullOrEmpty(SslCipherSpec)) props[MQC.SSL_CIPHER_SPEC_PROPERTY] = SslCipherSpec; // Bytes before the SSL secret key is renegotiated - a dead option until the options sweep. if (SslKeyResetCount > 0) props[MQC.SSL_RESET_COUNT_PROPERTY] = SslKeyResetCount; if (!string.IsNullOrEmpty(SslCertLabel)) props[MQC.SSL_CERT_STORE_PROPERTY] = SslCertLabel; if (!string.IsNullOrEmpty(SslPeerName)) props[MQC.SSL_PEER_NAME_PROPERTY] = SslPeerName; if (!string.IsNullOrEmpty(SslKeyRepository)) MQEnvironment.SSLKeyRepository = SslKeyRepository; return props; } /// /// The connection an endpoint without connectionFactory describes on its URI: the inline options, with the /// managed client transport the inline form has always used. /// internal static IbmMqConnectionFactory FromOptions(IbmMqEndpointOptions options) => new() { Host = options.Host, Port = options.Port, Channel = options.Channel, QueueManager = options.QueueManager, User = options.User, Password = options.Password, ClientName = options.ClientId, TransportType = MQC.TRANSPORT_MQSERIES_MANAGED, SslCipherSpec = options.SslCipherSpec, SslCertLabel = options.SslCertLabel, SslPeerName = options.SslPeerName, SslKeyRepository = options.SslKeyRepository, SslKeyResetCount = options.SslKeyResetCount, TemporaryModel = options.TemporaryModel, CCSID = options.CCSID, }; /// Opens an XMS connection (the event-driven consumer and the reply listener) to this queue manager. internal IBM.XMS.IConnection CreateXmsConnection() { var factory = IBM.XMS.XMSFactoryFactory.GetInstance(IBM.XMS.XMSC.CT_WMQ).CreateConnectionFactory(); factory.SetStringProperty(IBM.XMS.XMSC.WMQ_HOST_NAME, Host); factory.SetIntProperty(IBM.XMS.XMSC.WMQ_PORT, Port); factory.SetStringProperty(IBM.XMS.XMSC.WMQ_CHANNEL, Channel); factory.SetStringProperty(IBM.XMS.XMSC.WMQ_QUEUE_MANAGER, QueueManager); factory.SetIntProperty(IBM.XMS.XMSC.WMQ_CONNECTION_MODE, IBM.XMS.XMSC.WMQ_CM_CLIENT); if (!string.IsNullOrEmpty(ClientName)) factory.SetStringProperty(IBM.XMS.XMSC.CLIENT_ID, ClientName); if (!string.IsNullOrEmpty(SslCipherSpec)) factory.SetStringProperty(IBM.XMS.XMSC.WMQ_SSL_CIPHER_SPEC, SslCipherSpec); // Bytes before the SSL secret key is renegotiated, the same contract as the MQ-classes connection. if (SslKeyResetCount > 0) factory.SetIntProperty(IBM.XMS.XMSC.WMQ_SSL_KEY_RESETCOUNT, SslKeyResetCount); // The model of the temporary queue the reply listener creates (CreateTemporaryQueue). factory.SetStringProperty(IBM.XMS.XMSC.WMQ_TEMPORARY_MODEL, TemporaryModel); return string.IsNullOrEmpty(User) ? factory.CreateConnection() : factory.CreateConnection(User, Password); } }