Skip to content

Spike: Add IBM MQ broker throughput collection#5463

Closed
ramonsmits wants to merge 3 commits intomasterfrom
ibmmq-broker-throughput
Closed

Spike: Add IBM MQ broker throughput collection#5463
ramonsmits wants to merge 3 commits intomasterfrom
ibmmq-broker-throughput

Conversation

@ramonsmits
Copy link
Copy Markdown
Member

@ramonsmits ramonsmits commented May 7, 2026

Pairs with:

Summary

  • Implements IBrokerThroughputQuery for the IBM MQ transport so the licensing component's daily throughput collection covers IBM MQ deployments. Statistics are read from SYSTEM.ADMIN.STATISTICS.QUEUE (configurable) and aggregated per UTC day from MQIAMO_GETS counters inside MQGACF_Q_STATISTICS_DATA PCF groups.
  • Hand-rolled binary PCF parser walks the wire format directly via MQMessage.ReadInt4/ReadInt8/ReadString/SkipBytes. The IBM .NET MQ client (amqmdnetstd.dll v9.4.5) does not implement MQCFGR group-parameter parsing — new PCFMessage(MQMessage) throws "Unknown type" on every statistics message, so the documented .NET API can't be used.
  • Two settings expose multi-consumer flexibility:
    • LicensingComponent/IBMMQ/StatisticsQueue — source queue override, for setups where another tool already drains SYSTEM.ADMIN.STATISTICS.QUEUE and a forwarder, MQ topic subscription, or cluster channel delivers a per-consumer copy to a dedicated queue.
    • LicensingComponent/IBMMQ/StatisticsForwardingQueue — when set, ServiceControl re-publishes each consumed statistics message verbatim to a downstream queue inside the same syncpoint. Mirrors NServiceBus error/audit forwarding semantics.
  • When STATQ is disabled on the queue manager, ServiceControl still starts and runs. Connection-time validation (broker reachability, STATQ enablement, stats-queue access) is deferred from InitializeCore to TestConnectionCore and the first GatherThroughput cycle so host startup never blocks on broker I/O.

Positioning

Broker-side throughput collection is a fallback, not the primary path. The licensing usage report has three independent input sources: audit, monitoring, and broker. The monitoring source (NServiceBus endpoint metrics → Monitoring instance → ServiceControl) already produces per-day throughput data on every transport, including IBM MQ — provided every endpoint has metrics enabled and a Monitoring instance is running.

In our smoke test against the ibmmq-bridge-demo workload, broker and monitoring numbers tracked within 0.1 % on the same day for queues with a 1:1 receive pattern. They observe the same activity at different points in the pipeline.

This change is most valuable when:

  • Some endpoints are out of operator control and can't be reconfigured to emit metrics.
  • The Monitoring instance is not deployed.
  • Coverage parity needs verifying against the broker as ground truth.

For greenfield deployments where every NServiceBus endpoint can be configured with monitoring, enabling IBM MQ statistics events adds operational overhead (STATQ administration, MAXDEPTH tuning, additional permissions on the connecting user) without changing the report. The docs PR documents this trade-off and points readers toward monitoring first.

Implements IBrokerThroughputQuery for the IBM MQ transport so the
licensing component's daily throughput collection can include IBM MQ
deployments. Per-queue daily totals are aggregated from MQIAMO_GETS
counters inside MQGACF_Q_STATISTICS_DATA groups in PCF statistics
messages drained from SYSTEM.ADMIN.STATISTICS.QUEUE (configurable).

The IBM .NET MQ client (amqmdnetstd.dll v9.4.5) does not implement
MQCFGR group-parameter parsing, so a hand-rolled binary PCF parser
walks the wire format directly using MQMessage.ReadInt4/ReadInt8/etc.

Two settings expose multi-consumer flexibility:
- IBMMQ/StatisticsQueue overrides the source queue, for setups where
  another tool already drains SYSTEM.ADMIN.STATISTICS.QUEUE and a
  forwarder or topic subscription delivers a per-consumer copy.
- IBMMQ/StatisticsForwardingQueue causes ServiceControl to re-publish
  each consumed statistics message verbatim to a downstream queue in
  the same syncpoint, so a second consumer reads its own copy.

When STATQ is disabled on the queue manager, ServiceControl still
starts and runs; audit-based throughput collection acts as the
fallback. All connection-time validation (broker reachability, STATQ
enablement, stats-queue access) is deferred to TestConnectionCore and
the first GatherThroughput cycle so InitializeCore does not block on
broker I/O during host startup.

Verified by 9 unit tests and 3 integration tests against a real
IBM MQ broker (Podman icr.io/ibm-messaging/mq:latest).

The trailing-newline removals on ConnectionProperties.cs,
DeadLetterQueueCheck.cs and QueueLengthProvider.cs are an incidental
side effect of running dotnet format over the project to satisfy the
.editorconfig setting insert_final_newline = false.
ramonsmits added 2 commits May 7, 2026 14:40
The TestConnection error for STATQ(OFF) only mentioned audit-based
throughput as the fallback. Monitoring-based throughput is also a
fallback (and arguably the preferred path when endpoints are
configured for it). Update the message to reflect both options
without requiring queue-manager changes.
@ramonsmits ramonsmits closed this May 8, 2026
@ramonsmits ramonsmits changed the title Add IBM MQ broker throughput collection Spike: Add IBM MQ broker throughput collection May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants