Overview

The IBM MQ estate at a mature Saudi bank typically spans dozens of queue managers, hundreds of queues, and consumers ranging from ACE integration flows to COBOL batch jobs reading directly off a local queue manager. MQ gives you: exactly-once delivery (with XA transactions), strict FIFO ordering within a queue, persistent storage with HA-replication via RDQM or Multi-Instance Queue Managers, and a 25-year track record of surviving everything a data-centre can throw at it. What it does not give you is consumer-group fan-out without duplicating queues, ordered replay from an arbitrary offset, schema enforcement at the broker, or the stream-processing layer that sits natively on Kafka via Kafka Streams or Apache Flink.

Kafka is not a replacement for MQ — it is a different tool for a different problem. MQ models task queues: each message has one logical owner, delivery is acknowledged, and the queue is a fifo buffer between producer and consumer. Kafka models event logs: each record is immutable, stored durably for a configurable retention window, and any number of consumer groups can read from any offset independently. The migration from MQ to Kafka is therefore a semantic migration as much as a technical one. Before moving the first message, the team must agree on what the queue was modelling and whether the event-log semantics are what the new consumers actually need.

This article covers the three bridging mechanisms available in the IBM stack — the IBM MQ Source Connector for Kafka Connect, ACE-based bridge flows, and the IBM Event Streams MQ bridge — and the operational discipline needed to run a live migration in a regulated banking environment without interrupting payment or settlement flows.

MQ and Kafka run in parallel during migration

The bridge does not replace MQ on day one. MQ continues to handle all existing consumers exactly as before. The bridge silently copies every message from MQ to Kafka. Only when a consumer team has verified that the Kafka path delivers equivalent messages — same content, same ordering semantics, within the agreed latency budget — does that consumer cut over. MQ is decommissioned only after every consumer has migrated and a 60-day zero-traffic window on the MQ path has been confirmed.

Bridge vs Migrate vs Rewrite

Three options exist for moving from MQ to Kafka. The right choice depends on how tightly the queue semantics are coupled to the consumer implementation.

Bridge (copy-and-forward): a connector or ACE flow reads every message from the MQ queue and publishes it to a Kafka topic. MQ and Kafka run in parallel. Consumers migrate one by one; MQ is retired last. This is the lowest-risk option because MQ remains the system of record throughout the migration. If a Kafka consumer has a bug, the team can discard the consumer group offset and re-read from the topic — and if the Kafka path fails entirely, the MQ path continues uninterrupted.

Dual-write: the producer writes to both MQ and Kafka simultaneously. No bridge is needed; consumers migrate without coordination. The cost is two writes per message on the producer side, with the consistency question of what happens if one write succeeds and the other fails. Dual-write is appropriate only when the producer is already being modified as part of a broader modernisation — it adds unnecessary complexity if the producer team is not otherwise touched.

Direct Kafka migration: the producer is rewritten to target Kafka; MQ queues are retired; existing MQ consumers must migrate before go-live. This is the high-risk option: all consumers must be ready simultaneously, the cutover is a flag-day event, and the rollback path requires either restoring MQ or replaying from a Kafka offset that existed before the cutover. Only viable for new services or for queue/consumer pairs where both sides are owned by the same team.

In a regulated bank, bridge is almost always correct. The bridge can be deployed and validated with zero impact on existing MQ flows. Consumer teams get months to migrate at their own pace. The only cost is the latency added by the bridge — typically 20–100 ms for the Kafka Connect MQ Source Connector, acceptable for most event-driven use cases. Payment STP flows with strict latency budgets may require the ACE bridge with a dedicated broker path instead.

Kafka MQ Source Connector

The IBM MQ Source Connector for Kafka Connect (available from IBM as a Jar or via the IBM Event Streams operator) reads messages from an IBM MQ queue using the JMS 2.0 API and publishes them to a Kafka topic. It supports exactly-once semantics (via Kafka Connect’s exactly-once source connector framework with Kafka 3.3+), configurable message format conversion (bytes, string, or JSON), and dead-letter queue routing for messages that cannot be converted.

mq-source-connector.jsonjson
{
  "name": "mq-payments-source",
  "config": {
    "connector.class": "com.ibm.eventstreams.connect.mqsource.MQSourceConnector",
    "tasks.max": "4",

    // IBM MQ connection
    "mq.queue.manager":         "PAYQM01",
    "mq.connection.mode":        "client",
    "mq.connection.name.list":   "mq-host-1(1414),mq-host-2(1414)",
    "mq.channel.name":           "KAFKA.BRIDGE.SVRCONN",
    "mq.queue":                  "PAYMENTS.EVENTS.OUT",
    "mq.user.authentication.mqcsp": "true",
    "mq.username":              "${file:/opt/kafka/connect-secret:mq-username}",
    "mq.password":              "${file:/opt/kafka/connect-secret:mq-password}",
    "mq.ssl.cipher.suite":       "TLS_AES_256_GCM_SHA384",
    "mq.ssl.peer.name":          "CN=PAYQM01,O=Example Org,C=XX",

    // Message conversion
    "mq.message.body.jms":       "true",
    "mq.record.builder":         "com.ibm.eventstreams.connect.mqsource.builders.DefaultRecordBuilder",
    "value.converter":           "org.apache.kafka.connect.converters.ByteArrayConverter",
    "key.converter":             "org.apache.kafka.connect.storage.StringConverter",

    // MQMD headers forwarded as Kafka headers
    "mq.jms.properties.copy.to.kafka.headers": "true",

    // Target Kafka topic
    "topic": "banking.payments.events.raw",

    // Exactly-once and ordering
    "exactly.once.source.support": "enabled",
    "mq.exactly.once.state.queue": "KAFKA.BRIDGE.STATE",

    // Dead-letter queue for unconvertible messages
    "mq.error.queue.put":        "true",
    "errors.deadletterqueue.topic.name": "banking.payments.events.dlq",
    "errors.tolerance":          "all",
    "errors.log.enable":         "true"
  }
}

Key configuration decisions: tasks.max controls parallelism. Each task gets an independent JMS session and reads from the same queue; MQ assigns messages to tasks in arrival order within the same session, so increasing tasks increases throughput at the cost of per-message ordering guarantees (messages from different tasks may land in different Kafka partitions in out-of-arrival-order). For payment events where ordering per account matters, use a single task with a key extractor that assigns the account number as the Kafka record key — Kafka then guarantees ordering within the partition for that account. mq.exactly.once.state.queue must be a persistent, non-transactional queue on the same queue manager that persists connector state across restarts; without it, the connector falls back to at-least-once.

ACE Bridge Pattern

When the Kafka Connect MQ Source Connector’s latency profile (20–100 ms) is too high for latency-sensitive flows — real-time fraud scoring, payment STP with a 500 ms SLA, intraday liquidity monitoring — use an ACE message flow as the bridge instead. ACE can deliver messages from an MQ queue to Kafka in under 10 ms end-to-end because the ACE runtime holds a persistent JMS session and a persistent Kafka producer in the same JVM, with no network round-trip between them.

The bridge flow pattern: MQInput node (auto-ack disabled; commits only after Kafka produce succeeds) → ESQL Compute node (extract MQMD headers, map to Kafka record headers, transform message body) → KafkaProducer node (synchronous send with acks=all; on failure, the exception flows to an error handler that moves the message to the ACE DLQ rather than leaving it uncommitted on the MQ queue). The reverse bridge (Kafka → MQ, for consumers that cannot be migrated) uses KafkaConsumer node → ESQL Compute → MQOutput node.

MQToKafkaBridge.esqlsql
CREATE COMPUTE MODULE MapMQHeadersToKafka

  CREATE FUNCTION Main() RETURNS BOOLEAN
  BEGIN

    -- Preserve MQMD correlation and message IDs as Kafka headers
    DECLARE mqmd REFERENCE TO InputRoot.MQMD;

    SET OutputLocalEnvironment.Kafka.Output.Headers.mq.msgid       = mqmd.MsgId;
    SET OutputLocalEnvironment.Kafka.Output.Headers.mq.correlid    = mqmd.CorrelId;
    SET OutputLocalEnvironment.Kafka.Output.Headers.mq.format       = TRIM(mqmd.Format);
    SET OutputLocalEnvironment.Kafka.Output.Headers.mq.accountid    = mqmd.AccountingToken;
    SET OutputLocalEnvironment.Kafka.Output.Headers.mq.puttime      = mqmd.PutDateTime;

    -- Map to CloudEvents 1.0 required attributes
    SET OutputLocalEnvironment.Kafka.Output.Headers.ce-specversion = '1.0';
    SET OutputLocalEnvironment.Kafka.Output.Headers.ce-type        = 'com.example.payments.initiated.v1';
    SET OutputLocalEnvironment.Kafka.Output.Headers.ce-source      = '/mq/PAYQM01/PAYMENTS.EVENTS.OUT';
    SET OutputLocalEnvironment.Kafka.Output.Headers.ce-id          =
        CAST(UUIDASCHAR AS CHARACTER);  -- new event ID, not MQ message ID
    SET OutputLocalEnvironment.Kafka.Output.Headers.ce-time        =
        CAST(mqmd.PutDateTime AS CHARACTER FORMAT 'yyyy-MM-dd''T''HH:mm:ss.SSSZ');

    -- Kafka partition key: account number extracted from ISO 20022 XML payload
    -- (guarantees per-account ordering within a partition)
    DECLARE payNS NAMESPACE 'urn:iso:std:iso:20022:tech:xsd:pain.001.001.11';
    DECLARE acctId CHARACTER
        InputRoot.XMLNSC.(payNS)Document.(payNS)CstmrCdtTrfInitn
                                .(payNS)PmtInf.(payNS)DbtrAcct.(payNS)Id.(payNS)IBAN;
    SET OutputLocalEnvironment.Kafka.Output.Key = acctId;

    -- Pass message body unchanged (raw XML bytes); transform to Avro happens
    -- in a separate downstream ACE flow subscribing from the .raw topic
    SET OutputRoot.BLOB.BLOB = InputRoot.BLOB.BLOB;

    RETURN TRUE;
  END;

END MODULE;
Commit ordering: MQ ack after Kafka produce, never before

The ACE MQInput node must be configured with Transaction mode: Yes and the KafkaProducer node must use a synchronous send (acks=all, no fire-and-forget). If Kafka produce fails, the ACE transaction is rolled back and the MQ message is returned to the queue. If the MQ ack is sent before the Kafka produce completes — which happens if the KafkaProducer is in asynchronous mode — a Kafka produce failure causes the message to be lost from MQ but never land in Kafka. In a regulated bank, that is an unrecoverable audit gap.

Message Format Translation

MQ messages in a banking environment are almost universally one of three formats: ISO 20022 XML (pain.001, pacs.008, camt.054 and their variants), ISO 8583 binary or ASN.1 (card-network messages), or proprietary fixed-length or CSV (batch files from core banking or ERP). Kafka consumers — especially stream-processing jobs and analytics pipelines — expect Avro with a schema registered in the Schema Registry, or at minimum JSON with a declared schema.

The translation strategy depends on who owns the schema: if the ISO 20022 message already has an Avro mapping defined in the schema registry (as is increasingly the case with ISO 20022 MX adoption for SWIFT and SAMA RTGS integration), the bridge converts in-flight. If no Avro schema exists yet, publish the raw bytes to a .raw topic first, then run a separate transform consumer that converts and publishes to a versioned .v1 topic. This decouples schema evolution from bridge operation — the bridge never needs to change when the schema is updated.

For ISO 20022 XML to Avro, the mapping is field-level: each XML element that maps to a business concept (debtor IBAN, creditor BIC, instructed amount, end-to-end reference) becomes a named Avro field. Fields with no Kafka consumer interest are omitted from the Avro schema but preserved in a catch-all raw_xml bytes field for auditability. The enrichment flow adds computed fields: a canonical event_time in epoch milliseconds (from MQMD PutDateTime, not from the XML — the XML timestamp may reflect the originating bank’s clock, which may differ from the queue manager’s clock by seconds), and a source_queue string for lineage.

payment-event-v1.avscjson
{
  "namespace": "com.example.payments",
  "type": "record",
  "name": "PaymentInitiated",
  "doc": "ISO 20022 pain.001 bridged from MQ to Kafka. Schema v1.",
  "fields": [
    { "name": "event_id",       "type": "string",
      "doc": "CloudEvents ce-id. UUID assigned at bridge time." },
    { "name": "event_time",     "type": "long",
      "logicalType": "timestamp-millis",
      "doc": "MQMD PutDateTime epoch ms. Authoritative timestamp for event ordering." },
    { "name": "mq_msgid",       "type": "bytes",
      "doc": "Original MQMD MsgId for MQ/Kafka correlation and audit." },
    { "name": "debtor_iban",    "type": "string" },
    { "name": "creditor_bic",   "type": "string" },
    { "name": "creditor_iban",  "type": "string" },
    { "name": "amount",         "type": { "type": "bytes", "logicalType": "decimal",
                              "precision": 18, "scale": 2 } },
    { "name": "currency",      "type": "string" },
    { "name": "end_to_end_id", "type": "string" },
    { "name": "source_queue",  "type": "string",
      "default": "PAYQM01/PAYMENTS.EVENTS.OUT" },
    { "name": "raw_xml",        "type": ["null", "bytes"], "default": null,
      "doc": "Original ISO 20022 XML payload preserved for audit. Nullable after retention expires." }
  ]
}
Decimal amounts: never use float or double

ISO 20022 monetary amounts are fixed-point decimal values. Avro’s bytes type with logicalType: decimal is the only correct representation — it stores the value as an unscaled integer in two’s complement big-endian bytes, which round-trips without floating-point precision loss. Using Avro float or double for monetary amounts is a critical correctness bug that SAMA audit examiners will find in a schema review. Use Avro decimal at every hop from MQ to Kafka to Flink to the data warehouse.

Consumer Group Cutover

Consumer cutover is the controlled migration of an MQ message consumer to read from the Kafka topic instead. The dual-consume pattern runs both the MQ consumer and a new Kafka consumer in parallel, compares results for a validation window (typically 1–4 weeks), and then stops the MQ consumer after the Kafka consumer is confirmed correct. The MQ queue continues to receive messages from the bridge throughout; stopping the MQ consumer does not remove the queue or the bridge.

The cutover gate is binary: the consumer either reads from MQ or from Kafka, not both. Implement it with a configuration flag in the consumer’s environment (a ConfigMap value in Kubernetes, a property in IBM App Connect, or an application-level feature flag). Never implement it in code as a conditional that branches at message processing time — the dual-processing footprint creates ordering anomalies when both paths produce output to a downstream system simultaneously.

consumer-cutover.shshell
#!/usr/bin/env bash
# Pre-cutover: validate Kafka consumer group lag is zero (caught up to live)
kafka-consumer-groups.sh \
  --bootstrap-server kafka:9092 \
  --describe \
  --group fraud-detection-svc

# Expected output before cutover (all partitions at LAG=0):
# GROUP                   TOPIC                           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG
# fraud-detection-svc     banking.payments.events.v1      0          48201           48201           0
# fraud-detection-svc     banking.payments.events.v1      1          51889           51889           0
# fraud-detection-svc     banking.payments.events.v1      2          49703           49703           0

# Cutover: set feature flag in consumer ConfigMap (zero-downtime rolling restart)
kubectl patch configmap fraud-detection-config \
  -p '{"data":{"MESSAGING_BACKEND":"kafka","MQ_ENABLED":"false"}}'

kubectl rollout restart deployment/fraud-detection-svc
kubectl rollout status deployment/fraud-detection-svc

# Post-cutover: verify MQ queue depth drops to zero (no new MQ consumers reading)
# MQ queue depth should remain at 0 for the bridge backlog; bridge continues to publish
echo "display qstatus(PAYMENTS.EVENTS.OUT) all" | \
  runmqsc PAYQM01 | grep CURDEPTH

Validation criteria before cutting over a consumer: (1) the Kafka consumer group lag for all partitions has been at zero for at least 72 continuous hours, (2) a sample of 1,000 messages has been shadow-processed by the Kafka consumer and the output compared to the MQ consumer output with zero discrepancy, (3) the Kafka consumer has processed at least one full day of peak traffic (Friday morning in KSA banking, the highest payment volume period), and (4) the consumer team has a rollback plan — resetting the config flag — documented and tested in a non-production environment.

Dead-Letter Handling Across the Boundary

The bridge introduces a new DLQ topology. MQ already has a dead-letter queue (SYSTEM.DEAD.LETTER.QUEUE or a configured application DLQ) for messages that cannot be delivered. Kafka has its own DLQ topic convention (suffixed .dlq or .dead-letter). With a bridge, messages can fail at multiple points: in the MQ-to-Kafka bridge (conversion failure), in the Kafka consumer (processing failure), or in the ACE transform flow (schema validation failure). Each failure point must have a named DLQ and an owner.

The bridge DLQ topology: MQ KAFKA.BRIDGE.DLQ receives messages that the Kafka Connect connector or ACE bridge cannot convert or publish (network failure after retry exhaustion, malformed XML, schema mismatch that blocks serialisation). banking.payments.events.dlq Kafka topic receives records that the Kafka consumer rejects after retry exhaustion. The two DLQs are intentionally separate — a message in the MQ DLQ was never published to Kafka; a message in the Kafka DLQ was published but not processed. The remediation workflow differs for each.

Poison-pill detection on the bridge: a message that fails conversion consistently across retries is a poison pill. The connector’s errors.retry.timeout must be bounded (default is infinite; set to 300,000 ms in production). After the timeout, the message is moved to the bridge DLQ with error headers (the exception type, the stack trace summary, and the original MQMD fields) appended. Never let a single poison pill stall the entire bridge; configure errors.tolerance: all to skip the failing message after the retry timeout, with a mandatory alert on the DLQ metric.

Unmonitored DLQs cause silent data loss in regulated payment flows

An MQ DLQ that fills silently means payment events are being dropped from the bridge. SAMA’s operational resilience guidelines and ISO 20022 reconciliation requirements mean that every missed payment event must be detectable and recoverable. Alert on MQ queue depth for KAFKA.BRIDGE.DLQ with a threshold of 1 — any message in the bridge DLQ is an incident. Alert on the Kafka DLQ topic consumer-group lag with a threshold of 10. Neither DLQ should ever be silent for more than the agreed SLA for incident detection.

Observability During Migration

Running MQ and Kafka in parallel creates an observability gap: a message can be in-flight on either path, in a DLQ on either side, or delayed by bridge latency, without any single dashboard showing the complete picture. The minimum viable observability stack during migration consists of three layers: MQ queue depth metrics, Kafka consumer-group lag metrics, and end-to-end message correlation traces.

MQ metrics: expose queue depth (CURDEPTH), put rate, and get rate for every queue involved in the migration via the IBM MQ Exporter for Prometheus (available from the IBM MQ GitHub repository). Scrape at 30-second intervals. Alert on: source queue depth above the 95th-percentile baseline (indicating bridge backpressure), DLQ depth above 0 (indicating conversion failures), and state queue depth growth (indicating the exactly-once connector is falling behind).

Kafka metrics: expose consumer-group lag per topic partition via the standard kafka_consumer_group_lag JMX metric or via the Kafka Exporter for Prometheus. Alert on: aggregate lag above 10,000 records for payment event topics (indicating consumer backpressure or consumer failure), DLQ topic record count growth, and schema registry compatibility check failures (indicating a producer is publishing a message that breaks the registered schema).

End-to-end correlation: the MQMD CorrelId and the CloudEvents ce-id must both be logged at every processing hop. A payment event that enters MQ as message ID AMQ1234 must be traceable to a Kafka record by its mq.msgid header, to the ACE transform output by the CloudEvents ce-id, and to the downstream consumer output by whatever correlation ID the consumer propagates. Without this chain, a missing payment event cannot be located across the boundary during a production incident.

Steps to Bridge IBM MQ to Kafka in a Regulated Bank

  1. Pre-flight: inventory and risk assessment

    List every queue to be bridged with its current message rate (put/s and get/s), peak queue depth, message size distribution, and the list of consuming applications. Identify queues with XA transactional consumers — these cannot be bridged with the Kafka Connect connector alone and require an ACE bridge with two-phase commit. Identify queues used by COBOL batch consumers that read in deferred mode — these cannot migrate to Kafka without a code change on the consumer side, and may need a Kafka-to-MQ reverse bridge to continue operating. Document the migration as a phased plan with explicit go/no-go gates for each queue.

  2. Deploy bridge infrastructure

    Deploy Kafka Connect workers on the same network segment as the IBM MQ queue manager to minimise bridge latency. Configure the Kafka Connect worker with 4–8 worker threads per instance and at least two instances for HA. Create the Kafka topics with appropriate partition counts (match the expected peak throughput divided by the target per-partition throughput) and replication factor 3. Deploy the Schema Registry. Configure monitoring and alerting for bridge DLQ, source queue depth, and Kafka lag before the first connector is deployed.

  3. Shadow run: bridge without Kafka consumers

    Deploy the Kafka Connect MQ Source Connector in production against the first queue. Verify that messages flow from MQ to Kafka with correct content, correct headers (MQMD fields preserved), and correct partition assignment (key-based partitioning working as expected). Run the shadow for a minimum of 5 business days. Compare MQ put rate to Kafka produce rate — they must match within 0.1%. Confirm no bridge DLQ growth. Confirm exactly-once state queue remains stable. Only proceed when shadow run is clean.

  4. Consumer validation: dual-consume

    Deploy new Kafka consumers in shadow mode: they read from the Kafka topic but write their output to a validation store rather than to production. The existing MQ consumers continue to run unchanged. Compare Kafka consumer output to MQ consumer output for a validation window of 10 business days. Any discrepancy in message content, ordering within an account, or completeness (message counts must match between MQ and Kafka consumers) blocks cutover for that consumer. Fix the bridge configuration, transform flow, or consumer logic before proceeding.

  5. Consumer cutover

    Execute the cutover for each consumer team in a planned maintenance window (not during peak payment hours: avoid 09:00–11:00 KSA local time on Sunday–Thursday). Update the consumer configuration flag to MESSAGING_BACKEND=kafka. Restart the consumer service. Monitor for 30 minutes: Kafka consumer lag must remain near zero, error rates must not increase, downstream system outputs must continue to arrive with the expected frequency. If any indicator degrades, roll back by resetting the configuration flag. Do not cut over more than one consumer team per day.

  6. MQ decommission gate

    An MQ queue is eligible for decommission only when: (a) all consumer teams have confirmed cutover and their Kafka consumers have been in production for at least 60 calendar days, (b) the MQ queue depth has been zero for the entire 60-day window (monitored at 5-minute intervals, no exceptions), (c) the SAMA audit log for the queue shows no get operations from any application other than the bridge connector during the 60-day window, and (d) a named approver at VP level has signed off the decommission checklist. Remove the bridge connector only after the queue is confirmed decommissioned.

Approach Comparison

Approach Latency Exactly-once Ordering Effort Best for
Kafka Connect MQ Source 20–100 ms Yes (Kafka 3.3+ with state queue) Per-partition, key-based Low — JSON config, no code Most event and notification queues; analytics pipelines
ACE bridge flow 5–15 ms Yes (ACE XA + Kafka acks=all) Strict FIFO within ACE worker thread Medium — ACE flow + ESQL Low-latency STP paths; ISO 20022 XML transform; XA consumers
IBM Event Streams MQ bridge 10–50 ms At-least-once; no state queue Arrival order; no key-based partitioning Low — operator-managed; IBM support included IBM Event Streams-managed Kafka; teams without Kafka Connect expertise
Direct Kafka migration Native Kafka (1–5 ms) Yes (idempotent producer + transactional consumers) Per-partition, key-based High — producer and all consumers rewritten New services; queues where both producer and all consumers are owned by one team