Path: redb-route/redb.Route.IbmMq/IbmMqEndpointOptions.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/IbmMqEndpointOptions.cs ---- using redb.Route.Abstractions; using redb.Route.Batching; using redb.Route.Core; namespace redb.Route.IbmMq; /// /// Destination type for IBM MQ endpoints. /// public enum IbmMqDestinationType { /// Point-to-point queue. Queue, /// Publish/subscribe topic. Topic } /// /// Consumer receive strategy. /// public enum IbmMqReceiveMode { /// /// Synchronous MQGET-WAIT poll loop (IBM.WMQ). Default, battle-tested, but the managed /// client carries an internal ~500 ms poll tick, so delivery latency is ~250–500 ms. /// Poll, /// /// Event-driven push via XMS .NET MessageListener (IBM.XMS). The broker pushes /// messages the instant they arrive, dropping delivery latency to <50 ms. This is the /// only supported event-driven receive path on the managed .NET client (IBM.WMQ exposes no /// public MQCB). Opt-in — remains the default fallback. /// Listener } /// /// IBM MQ message persistence mode. /// public enum IbmMqPersistence { /// Use the queue's default persistence setting. AsQDef = -1, /// Non-persistent (faster, may be lost on restart). NonPersistent = 0, /// Persistent (written to disk, survives restart). Persistent = 1 } /// /// IBM MQ message type (MQMT_*). /// public enum IbmMqMessageType { /// Normal one-way message. Datagram = 8, /// Request expecting a reply. Request = 1, /// Reply to a request. Reply = 2, /// Report message. Report = 4 } /// /// Target client mode — controls whether MQRFH2 headers are included. /// public enum IbmMqTargetClient { /// Include MQRFH2 for JMS interoperability. Jms, /// Raw MQMD only — no RFH2 header. Mq } /// /// RPC correlation pattern — how replies are matched to requests. /// public enum IbmMqCorrelationPattern { /// Reply CorrelId = Request MsgId (standard IBM MQ pattern). MsgId, /// Reply CorrelId = Request CorrelId (JMS pattern). CorrelId } /// /// Endpoint options for IBM MQ transport. All properties are auto-bound from URI query parameters. /// /// URI format: ibmmq:QUEUE.NAME?host=mq-host&port=1414&channel=DEV.APP.SVRCONN&queueManager=QM1 /// /// public sealed class IbmMqEndpointOptions : EndpointOptions { // ── Connection ─────────────────────────────────────────────────── /// Named connection factory from registry. Takes priority over inline params. [RegistryReference(typeof(IbmMqConnectionFactory))] public string? ConnectionFactory { get; set; } /// /// A registry reference (#name) to an that /// decides which headers this endpoint carries between the exchange and the message's header catalogue (a /// request, a consumed message, a reply both ways), in place of . /// [RegistryReference(typeof(IHeaderFilterStrategy))] public string? HeaderFilterStrategy { get; set; } /// Queue manager hostname. (default: localhost) public string Host { get; set; } = "localhost"; /// Queue manager listener port. (default: 1414) public int Port { get; set; } = 1414; /// Server-connection channel name. (default: DEV.APP.SVRCONN) public string Channel { get; set; } = "DEV.APP.SVRCONN"; /// Queue manager name. (required) public string QueueManager { get; set; } = "QM1"; /// Authentication user. public string? User { get; set; } /// Authentication password. [Sensitive] public string? Password { get; set; } /// Client identifier for connection tracking. public string? ClientId { get; set; } // ── Destination ────────────────────────────────────────────────── /// Destination type: Queue or Topic. (default: Queue) public IbmMqDestinationType DestinationType { get; set; } = IbmMqDestinationType.Queue; // ── Consumer ───────────────────────────────────────────────────── /// /// Receive strategy: Poll (synchronous MQGET-WAIT, default) or Listener /// (event-driven XMS MessageListener, <50 ms latency). (default: Poll) /// public IbmMqReceiveMode ReceiveMode { get; set; } = IbmMqReceiveMode.Poll; /// Concurrent consumer sessions: a number or "auto" (= max(CPU, 2)). Default 1. Topics clamp to 1 (parallel subscriptions would duplicate delivery). // A string so "auto" binds verbatim instead of silently degrading to the int default. public string? ConcurrentConsumers { get; set; } /// Resolved consumer parallelism (see ). public int ResolvedConcurrentConsumers => ConcurrencyOption.Resolve(ConcurrentConsumers, "concurrentConsumers"); /// MQGET wait interval in milliseconds. 0 = no wait. (default: 5000) public int WaitInterval { get; set; } = 5000; /// /// With transacted=true or in batch mode: a message backed out this many times (over the input queue's BOTHRESH) goes to /// instead of the route, in the unit of work of its read. 0 = off. /// public int BackoutThreshold { get; set; } /// /// Queue a poison message goes to (and, in batch mode, a request), over the input queue's BOQNAME; without either, the /// queue manager's dead letter queue. /// public string? BackoutQueue { get; set; } /// /// Pause after a backout, in milliseconds (default 1000): once the consumer backs out a failed message /// (transacted=true) or a failed batch, none of its workers starts another MQGET until the pause has passed, /// so the message does not come straight back; IBM MQ itself does not delay a backed-out message. 0 = no pause, the /// message is read again at once. Poll and batch modes; in listener mode the XMS client sets the tempo and the /// option does not act. A worker already waiting in MQGET when another worker backs out is not held back. This /// option is redb's addition: Apache Camel has no such option. /// public int BackoutDelay { get; set; } = 1000; /// /// Apache Camel disableReplyTo: the consumer does not act on a request's reply-to. It sends no reply, and a /// batch consumer takes such a message into its batch instead of moving it to the backout queue. /// public bool DisableReplyTo { get; set; } // ── Batch mode ── /// /// Batch mode (Apache Camel batching): the route gets one InOnly exchange whose body is a /// List<IMessage> of up to messages, read under syncpoint and committed /// once after the route (backed out when it fails). Poll receive mode only. /// public bool Batching { get; set; } /// Largest number of messages in a batch (default 100). Batch mode only. public int? MaxBatchMessages { get; set; } /// /// Batch mode: a batch with messages is sent on once no message came for this many milliseconds, restarted by /// every message (default 1000). /// public int PollTimeoutMs { get; set; } = 1000; /// Batch mode: a batch is sent on once this many milliseconds have passed since its first message. public int? BatchingIntervalMs { get; set; } /// The default of . internal const int DefaultMaxBatchMessages = 100; /// The batch options, or null outside batch mode. Set by . internal BatchOptions? Batch { get; private set; } /// /// Resolves the batch options. Fails, naming the endpoint, where batch mode cannot work: a batch option without /// batching=true, a value out of range, receiveMode=listener (batches are read with MQGET under /// syncpoint) and request-reply (replyTo=true: a batch is one-way). A batch also needs a backout or dead /// letter queue, checked when the consumer starts (the queue's BOQNAME and the queue manager's DEADQ count). /// internal void ResolveBatch(string endpoint) { Batch = BatchOptions.Resolve(endpoint, Batching, MaxBatchMessages, PollTimeoutMs, BatchingIntervalMs, DefaultMaxBatchMessages); if (Batch is null) return; if (ReceiveMode == IbmMqReceiveMode.Listener) throw new InvalidOperationException( $"Endpoint '{endpoint}': batching=true cannot be combined with receiveMode=listener: a batch is read with " + "MQGET under syncpoint and committed once. Use receiveMode=poll."); if (ReplyTo) throw new InvalidOperationException( $"Endpoint '{endpoint}': batching=true cannot be combined with replyTo=true: a batch is one-way (InOnly) " + "and nobody would answer a request in it."); } /// protected override string? UnknownParameterHint(string name) => name.Equals("batchSize", StringComparison.OrdinalIgnoreCase) ? "'batchSize' did nothing and is gone; batch mode is batching=true with maxBatchMessages=N, read under " + "syncpoint and committed once per batch." : null; /// Message selector expression (for topic subscriptions). public string? Selector { get; set; } /// Apply MQGMO_CONVERT on receive. (default: true) public bool Convert { get; set; } = true; // ── Producer ───────────────────────────────────────────────────── /// Message persistence mode. (default: AsQDef) public IbmMqPersistence Persistence { get; set; } = IbmMqPersistence.AsQDef; /// Expression override for persistence (resolves to enum name or numeric value). public string? PersistenceExpression { get; set; } /// Message priority. -1 = use queue default. (default: -1) public int Priority { get; set; } = -1; /// Expression override for priority (resolves to int). public string? PriorityExpression { get; set; } /// Message expiry in tenths of a second. -1 = unlimited. (default: -1) public int Expiry { get; set; } = -1; /// Expression override for expiry (resolves to int). public string? ExpiryExpression { get; set; } /// Target client mode — Jms (with MQRFH2) or Mq (raw MQMD). (default: Jms) public IbmMqTargetClient TargetClient { get; set; } = IbmMqTargetClient.Jms; /// Message type for outgoing messages. (default: Datagram) public IbmMqMessageType MessageType { get; set; } = IbmMqMessageType.Datagram; /// Expression override for message type (resolves to enum name or numeric value). public string? MessageTypeExpression { get; set; } // ── Transactions ───────────────────────────────────────────────── /// /// Consumer: true gets under syncpoint and commits (MQCMIT/MQBACK) with the route. Producer: whether the put /// joins the enclosing .Transacted() block. Unset, it follows the block: deferred until the database commits /// inside one, put at once outside. true requires a block and fails outside one; false puts at once /// even inside one. A request-reply producer () always puts at once and refuses true. /// public bool? Transacted { get; set; } // DeadLetterQueue/MaxRedeliveries are gone (the options sweep): both were declared // and read by nothing - a second vocabulary for poison handling next to the IMPLEMENTED one, // IBM MQ's native BackoutThreshold/BackoutQueue (BOTHRESH/BOQNAME) in the XMS engine. // ── RPC (Request/Reply) ────────────────────────────────────────── /// Enable request/reply pattern. (default: false) public bool ReplyTo { get; set; } /// /// Apache Camel preserveMessageQos: an ordinary (not request-reply) put keeps the redbIbmMq.ReplyToQueue and /// redbIbmMq.ReplyToQueueManager headers as the message's reply-to. Off by default, as in Camel's JMS: a message /// consumed with a sender's reply-to and forwarded to this endpoint does not carry that reply-to on, so no consumer /// answers into a queue of another system. The correlation id is always carried. /// public bool PreserveMessageQos { get; set; } /// Reply-to queue name. If empty, uses dynamic/temporary reply queue. public string? ReplyToQueue { get; set; } /// /// Model queue of the temporary reply queue opened when is empty: IBM MQ's /// TEMPMODEL, temporaryModel on its JMS connection factory. With connectionFactory set it is /// taken from that factory () instead. /// (default: SYSTEM.DEFAULT.MODEL.QUEUE) /// public string TemporaryModel { get; set; } = IbmMqConnectionFactory.DefaultTemporaryModel; /// Reply-to queue manager. If empty, uses local queue manager. public string? ReplyToQueueManager { get; set; } /// RPC timeout in seconds. (default: 30) public int Timeout { get; set; } = 30; /// How to correlate RPC replies. (default: MsgId) public IbmMqCorrelationPattern CorrelationPattern { get; set; } = IbmMqCorrelationPattern.MsgId; // ── SSL/TLS ────────────────────────────────────────────────────── /// SSL CipherSpec name (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 the key repository (.kdb file without extension). public string? SslKeyRepository { get; set; } /// Number of bytes before SSL secret key is renegotiated. 0 = disabled. public int SslKeyResetCount { get; set; } // ── Advanced ───────────────────────────────────────────────────── /// Coded Character Set ID for message body. (default: 1208 = UTF-8) public int CCSID { get; set; } = 1208; /// /// Allow writing the advanced/raw MQMD fields from exchange headers — message type, format, /// group id, message sequence number. (default: false, mirrors IBM MQ JMS WMQ_MQMD_WRITE_ENABLED) /// The standard JMS-equivalent fields (correlation id, priority, expiry, persistence, /// reply-to queue/manager) always forward from headers regardless of this flag. /// public bool MqmdWriteEnabled { get; set; } /// Populate all MQMD fields into exchange headers on receive. (default: true) public bool MqmdReadEnabled { get; set; } = true; /// public override void Validate() { if (string.IsNullOrWhiteSpace(QueueManager)) throw new ArgumentException("IBM MQ queueManager is required."); if (string.IsNullOrWhiteSpace(Host)) throw new ArgumentException("IBM MQ host is required."); if (string.IsNullOrWhiteSpace(Channel)) throw new ArgumentException("IBM MQ channel is required."); if (Port is < 1 or > 65535) throw new ArgumentException($"IBM MQ port must be 1–65535, got: {Port}"); _ = ConcurrencyOption.Resolve(ConcurrentConsumers, "concurrentConsumers"); // loud on garbage if (WaitInterval < 0) throw new ArgumentException($"IBM MQ waitInterval must be >= 0, got: {WaitInterval}"); if (BackoutDelay < 0) throw new ArgumentException($"IBM MQ backoutDelay must be >= 0, got: {BackoutDelay}"); if (Timeout < 1) throw new ArgumentException($"IBM MQ rpc timeout must be >= 1, got: {Timeout}"); // An IBM MQ object name: 1 to 48 characters. if (string.IsNullOrWhiteSpace(TemporaryModel) || TemporaryModel.Length > 48) throw new ArgumentException( $"IBM MQ temporaryModel must be a queue name of 1 to 48 characters, got: '{TemporaryModel}'"); } }