Lakshya

Infrastructure & Reliability · Middleware — Messaging · Chapter 25 of 33

IBM MQ from the inside

Queue managers, channels, transmission queues and units of work — how IBM MQ moves a payment between two data centres exactly once, the high-availability options from a pair of servers to a mainframe coupling facility, and the reason codes every MQ interview asks about.

8 min read1 diagramAll 33 chapters

IBM MQ is the message broker most large banks run their core integration on. It began as MQSeries in 1993, was renamed WebSphere MQ in 2002 and IBM MQ in 2014, and the names still overlap in job descriptions and in conversation — “MQ” on its own, in a bank, almost always means this product, though in a vendor-selection meeting it can mean Gartner’s Magic Quadrant instead. IBM’s own product blog says 98 of the top 100 global banks use IBM MQ; the figure is undated and unexplained, but no one disputes the direction.

The objects

ObjectWhat it isWhy it exists
Queue managerThe server process that owns queues, stores messages and runs channels. A bank has hundredsThe unit of administration, recovery and licensing
Local queueA queue that physically lives on this queue managerWhere messages wait for their consumer
Remote queue definitionA local name that points at a queue on another queue managerApplications put to a local name and never need to know where the target lives
Transmission queueA special local queue holding messages bound for another queue managerWhere messages wait while the other side is unreachable
Alias queueAnother name for a queueLets a queue be moved or renamed without changing applications
Model queueA template for queues created on demandTemporary reply queues for request/reply
ChannelA one-way connection between queue managers (sender and receiver), or between a client application and a queue manager (server-connection)The only way messages cross the network
ListenerThe process accepting network connections for channelsUsually on port 1414 by convention

An application connects to a queue manager in one of two ways. In bindings mode it runs on the same machine and talks to the queue manager through shared memory — fast, and common on the mainframe. In client mode it connects across the network through a server-connection channel — the norm for applications running in containers or on separate servers.

ONE MESSAGE BETWEEN TWO DATA CENTRES — AND WHERE IT WAITS WHEN THINGS FAIL DATA CENTRE A · QUEUE MANAGER QM1 DATA CENTRE B · QUEUE MANAGER QM2 Payments appMQPUT, then commitTransmission queueon QM1Local queuePAYMENTS.IN on QM2Core bankingMQGET in a unit of work channel over TLS QM1 itself downthe put fails at once:reason 2059Network or QM2 downit WAITS HERE; thechannel keeps retryingCore app downit WAITS HERE; thequeue depth climbsCore crashes mid-workrollback returns itto the queue THE PAYMENT IS NEVER IN TWO PLACES AND NEVER IN NONE. Between queue managers, a persistent message moves once and only once: QM1 keeps it until QM2 has committed it, and the channel’s sequence numbers resolve any batch left in doubt by a failure. Inside the core application, ‘exactly once’ still needs the database update and the MQGET committed together.
Why IBM MQ became the default for payments. At every step the message is either on disk in one committed place or in flight under a protocol that resolves failures without losing or doubling it. The failure annotations are what an interviewer is really asking about when they say “walk me through a message”.

Persistence and the recovery log

A persistent message is written to the queue manager’s recovery log before the put completes. That write, forced to disk, is the dominant cost of persistent messaging: the speed of the log disk sets the throughput ceiling of a queue manager, which is why logs go on the fastest, lowest-latency storage available and on different volumes from the queue files.

Log typeWhat it can recoverOperational cost
CircularRestart recovery: messages that were on the queue manager when it stoppedLow — log space is reused automatically
LinearRestart recovery and media recovery: rebuilding a damaged queue file from the logHigher — old log extents must be archived and deleted, or the disk fills

Units of work, backout and poison messages

An application gets and puts messages under syncpoint: nothing it does is visible or final until it commits, and a rollback undoes all of it — the message returns to the queue with its backout count increased by one. When the count passes the queue’s backout threshold, a well-written application moves the message to the named backout queue rather than trying again. When the unit of work must include a database update, the queue manager can act as the coordinator of an XA two-phase commit, or take part in one run by the application server.

IBM MQ MQSC (runmqsc)CURDEPTH is the depth; IPPROCS and OPPROCS show how many applications have the queue open for input and output — a climbing depth with IPPROCS of zero means the consumer is not even connected. MSGAGE is the age in seconds of the oldest message (queue monitoring must be enabled for it).
* Define a production queue: persistent by default, deep enough to buffer an outage,
* and a backout queue for poison messages after three failed attempts
DEFINE QLOCAL('PAYMENTS.IN') DEFPSIST(YES) MAXDEPTH(500000) +
       BOTHRESH(3) BOQNAME('PAYMENTS.BACKOUT')

* The first three commands of every MQ investigation
DISPLAY QLOCAL('PAYMENTS.IN') CURDEPTH IPPROCS OPPROCS
DISPLAY QSTATUS('PAYMENTS.IN') MSGAGE LGETTIME
DISPLAY CHSTATUS('QM1.TO.QM2') STATUS MSGS

Clusters are not high availability

IBM MQ clusters let many queue managers share definitions and spread messages across several instances of the same queue. They simplify administration and balance workload. They do not make a message highly available: a message already sitting on a queue manager that fails stays there, stranded, until that queue manager comes back. It is one of the most common misunderstandings in MQ architecture, and a favourite interview question.

The real high-availability options

OptionHow it worksWhere
Multi-instance queue managerActive and standby instances on two servers sharing networked storage; the standby takes over the files if the active one failsLinux, Windows, AIX
RDQM — Replicated Data Queue ManagerThree Linux nodes; the queue manager’s disk is replicated synchronously between them, and a cluster manager restarts it on a surviving nodeMQ Advanced, on Linux
Native HAThree replicas in containers; the active one streams its log to the other two, and a majority must confirm each write. Since MQ 9.4.2, Cross-Region Replication copies a Native HA group to a second region for disaster recoveryOpenShift or Kubernetes
Queue-sharing groupSeveral queue managers on the mainframe share queues held in the sysplex’s coupling facility, a shared memory structure; messages survive the loss of any one queue manager, and CICS can connect to the group rather than to one memberIBM Z (z/OS) only

CICS, the Customer Information Control System, is the mainframe transaction server behind much core banking; its tight integration with IBM MQ through queue-sharing groups is the single largest reason banks do not simply swap IBM MQ out.

Security

  • TLS on every channel, with a named cipher specification, so messages are encrypted on the network.
  • Channel authentication records (CHLAUTH), which block or map connections by address, certificate or user — the first line against an unknown client connecting to a production queue manager.
  • Connection authentication, which requires client applications to present a user and password or a certificate.
  • Object authorities, granting each application only the queues it needs, and only the operations it needs — put, get, browse.
  • Advanced Message Security (MQ Advanced only), which signs and encrypts the message body end to end, so even an administrator on an intermediate queue manager cannot read a payment.

Reason codes worth knowing by number

CodeNameWhat it usually means
2009MQRC_CONNECTION_BROKENThe network or the queue manager dropped the connection mid-operation
2033MQRC_NO_MSG_AVAILABLEA get found the queue empty — normal, not an error, when polling
2035MQRC_NOT_AUTHORIZEDSecurity refused the connection or the operation; the queue manager’s error log says why
2053MQRC_Q_FULLThe queue reached its maximum depth — the consumer has stopped or fallen far behind
2059MQRC_Q_MGR_NOT_AVAILABLEThe queue manager is down, or the listener or network is unreachable
2085MQRC_UNKNOWN_OBJECT_NAMEThe queue name does not exist on this queue manager — usually a configuration or environment mismatch

What MQ Advanced adds

IBM sells two main editions. The base product provides the messaging. MQ Advanced adds Advanced Message Security, RDQM and Native HA, and IBM MQ Managed File Transfer — file transfer carried over MQ channels, which links this sub-section to the file transfer one. IBM also provides connectors that move messages between IBM MQ and Kafka. What each edition costs is in messaging licensing.

Check yourself

What were IBM MQ's earlier names?MQSeries (1993), WebSphere MQ (2002), IBM MQ (2014).
What is a transmission queue?A local queue holding messages bound for another queue manager — where they wait while the other side is unreachable.
Bindings versus client connection?Bindings: same machine, shared memory, fast. Client: across the network through a server-connection channel.
If QM2 is down, where is the payment?On QM1's transmission queue, with the sender channel retrying.
What sets a queue manager's persistent throughput ceiling?The latency of forced writes to the recovery log disk.
Circular versus linear logging?Circular recovers from restarts only and reuses space; linear also supports media recovery but needs log housekeeping.
What happens to a message when its unit of work rolls back?It returns to the queue with its backout count incremented; past the threshold it should go to the backout queue.
Does an MQ cluster make messages highly available?No — it balances workload and shares definitions; a message on a failed queue manager is stranded until it returns.
Name the four HA options.Multi-instance queue managers, RDQM, Native HA (with Cross-Region Replication since 9.4.2), and z/OS queue-sharing groups.
Why is IBM MQ hard to replace in banks?Its integration with CICS and the mainframe through queue-sharing groups, plus interfaces like SWIFT's MQ adaptor.
What does reason code 2035 mean? 2053? 2059?Not authorised; queue full; queue manager not available.
What does Advanced Message Security add?End-to-end signing and encryption of the message body, so intermediate administrators cannot read it.
← What a message queue is, and why banks cannot live without oneKafka and IBM MQ: a log is not a queue →