Path: redb-route/tests/redb.Route.Tests.IbmMq/IbmMqConformanceTests.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/tests/redb.Route.Tests.IbmMq/IbmMqConformanceTests.cs
----
using redb.Route.Abstractions;
using redb.Route.IbmMq;
using redb.Route.Tests.Conformance;
namespace redb.Route.Tests.IbmMq;
///
/// The IBM MQ connector against , in poll receive mode. The queues of a queue
/// manager are fixed objects: every case reads DEV.QUEUE.CONFORMANCE of tests/docker/ibmmq/redb-tests.mqsc,
/// emptied before and after it, and its backout queue DEV.QUEUE.CONFORMANCE.BOQ is the dead letter queue.
///
/// How the cases map onto IBM MQ: attempts are the broker's own redelivery, transacted=true with
/// backoutThreshold set to the attempts (a message runs on backout counts 0 to attempts-1, then goes to the
/// backout queue); acknowledgement on receipt is the default consumer, whose MQGET takes the message outside a unit of
/// work; a batch always reads under syncpoint, so it takes only the threshold. backoutDelay=0 keeps the
/// redelivery quick. Runs in the IBM MQ collection, which runs alone: the restart case breaks the queue manager for
/// every connection of the suite. Expects IBM MQ at localhost:1414.
///
///
[Trait("Category", "Integration")]
[Collection("IbmMqIntegration")]
public sealed class IbmMqConformanceTests : ConnectorConformance
{
private const string Queue = "DEV.QUEUE.CONFORMANCE";
private const string BackoutQueue = "DEV.QUEUE.CONFORMANCE.BOQ";
private const string Login = "channel=DEV.APP.SVRCONN&queueManager=QM1&user=app&password=admin";
protected override IbmMqStand Stand => IbmMqStand.Instance;
protected override ConnectorTraits Traits { get; } = new()
{
AckOnReceipt = true, Transactions = true, DeadLetter = true, Concurrency = true, Batch = true,
};
protected override int BrokerPort => 1414;
protected override IComponent CreateComponent() => new IbmMqComponent();
protected override async Task CreateQueueAsync(bool deadLetter)
{
await EmptyAsync();
return new ConformanceQueue(Queue, deadLetter ? BackoutQueue : null);
}
protected override Task DeleteQueueAsync(ConformanceQueue queue) => EmptyAsync();
protected override string ConsumerUri(ConformanceQueue queue, ConsumerSettings settings)
{
// A batch starts only with a backout or dead letter queue to divert to, so the backout queue is always named;
// with no threshold it is not used outside a batch.
var uri = $"wmq:{queue.Name}?host=localhost&port={settings.Port ?? BrokerPort}&{Login}"
+ $"&waitInterval=500&backoutDelay=0&backoutQueue={BackoutQueue}";
if (settings.Attempts is { } attempts && !settings.AckOnReceipt)
uri += (settings.BatchSize is null ? "&transacted=true" : "") + $"&backoutThreshold={attempts}";
if (settings.Concurrency is { } concurrency)
uri += $"&concurrentConsumers={concurrency}";
if (settings.BatchSize is { } size)
uri += $"&batching=true&maxBatchMessages={size}&pollTimeoutMs={(int)settings.BatchWait.TotalMilliseconds}";
return uri;
}
// Left unset the producer follows a block too; that rule is IbmMqIntegrationTests' own.
protected override string ProducerUri(ConformanceQueue queue, bool transacted)
=> $"wmq:{queue.Name}?host=localhost&port={BrokerPort}&{Login}" + (transacted ? "&transacted=true" : "");
private async Task EmptyAsync()
{
await Stand.DrainAsync(Queue, TimeSpan.Zero);
await Stand.DrainAsync(BackoutQueue, TimeSpan.Zero);
}
}