Publishers

A publisher in IBM MQ is any program that announces an event to the enterprise by putting a message on a topic. The order service publishing retail/order/placed, the mainframe payment module emitting finance/payment/settled, or a microservice using JMS publish—all are publishers. They do not address subscriber queues directly; they trust the queue manager to fan out copies. That decoupling is the architectural win and the security challenge: PUB authority must be tight, payload schemas versioned, and publish rates monitored because one careless loop can flood every subscription matching #. This tutorial covers MQI open/put on topics, message descriptor fields beginners must set, persistence and correlation, JMS and REST alternatives, syncpoint behavior, retain for state topics, error codes when PUB is missing, and performance habits that keep pub/sub healthy in mixed COBOL and Java estates.

Publisher Responsibilities

Publishers own correct topic strings, serialization format (JSON, XML, fixed COBOL), persistence choice aligned with business durability, and correlation IDs for request/reply over topics when used. They do not own subscriber queue depth—yet publish storms can overwhelm slow subscribers indirectly when DEST queues fill and back-pressure policies trigger. Include message size discipline: large payloads multiply by subscriber count. Consider reference data patterns (publish an ID, consumers fetch detail) for huge objects.

Publisher put options beginners should understand
ConceptEffectWhen to use
Persistent publishCopies survive restart if DEST queues persistentFinancial or audit events
Non-persistent publishLower overhead; loss if subs offlineTelemetry with tolerance for gaps
Correlation IDLinks related messagesRequest/reply over topics
Retain (if supported)Last message kept for new subsConfig/status topics only
SyncpointCommit/rollback with DB2 or CICSTransactional outbox patterns

MQI Publisher Pattern

Typical sequence: MQCONNX, MQOPEN topic for output (or MQPUT1 with resolved string per API style), fill MQMD (format, persistence, correlation), MQPUT, MQCMIT or rollback, MQCLOSE, MQDISC. Topic object name in OPEN reduces string typos. PMO options control context and retain flags per IBM definitions for your release.

c
1
2
3
4
5
6
7
8
9
/* Illustrative MQI publish — error handling omitted */ MQCONNX(QMgrName, &cno, &Hcon, &CompCode, &Reason); MQOPEN(Hcon, &od, MQOO_OUTPUT, &Hobj, &CompCode, &Reason); /* od is descriptor for topic name or string */ memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId)); md.Persistence = MQPER_PERSISTENT; memcpy(md.Format, MQFMT_STRING, (size_t)MQ_FORMAT_LENGTH); MQPUT(Hcon, Hobj, &md, &pmo, buflen, buffer, &CompCode, &Reason); MQCMIT(Hcon, &CompCode, &Reason);

JMS and Other Clients

JMS publishers use session.createProducer(topic) and producer.send(message). Connection factory must point at SVRCONN with correct MCAUSER and PUB rights. .NET XMS and Java share similar models. Node and Python clients wrap MQI—same authority rules. REST POST to messaging API is a publisher without local MQI—still needs PUB authority for the authenticated user.

PUB Authority and Errors

Missing PUB yields not authorized on put (2035 on distributed). Fix setmqaut -t topic -n 'branch/#' -p ServiceId +pub. Publishers should not run as mqm or admin MCAUSER in production. Map SVRCONN to dedicated producer IDs. CHLAUTH and TLS protect the connection; PUB protects the topic tree.

Idempotency and Duplicate Events

At-least-once middleware and application retries can publish duplicates. Subscribers should dedupe using business keys in payload or message ID when exactly-once semantics are required. Publishers can set MsgId or group identifiers; document whether duplicate MsgId is possible from your retry logic.

Explainer: Town Crier

The publisher is the town crier shouting news in the square (topic). The crier does not walk to every house; listeners who signed up get copies delivered to their doors (subscriber queues).

Anti-Patterns

  • Loop publishing to # patterns for “broadcast” when a single queue suffices.
  • Putting megabyte payloads to topics with ten subscribers—40 MB per event.
  • Using non-persistent publish for money movement without acceptance of loss.
  • Hard-coding topic strings in 200 programs instead of topic objects.

Explain Like I'm Five: Publishers

A publisher is the kid who presses the button on the school intercom to announce one message to everyone listening for that kind of news.

Practice Exercises

Exercise 1

Write setmqaut for producer APP1 to PUB on inventory/stock/# only.

Exercise 2

Estimate disk when persistent 2 KB publish matches six durable subscriptions.

Exercise 3

List MD fields you set for JSON order event versus COBOL copybook event.

Frequently Asked Questions

Frequently Asked Questions

Test Your Knowledge

Test Your Knowledge

1. Publisher needs authority:

  • PUB on topic
  • GET on all DEST
  • Only channel
  • DLQ only

2. Fan-out is performed by:

  • Queue manager pub/sub
  • Publisher loop
  • FTP
  • JCL

3. MQPUT to topic sets routing via:

  • Topic in MD or topic handle
  • CONNAME
  • XMITQ
  • BOQNAME

4. Persistent publish with 5 subs:

  • Up to 5 persistent copies
  • One copy only
  • Zero disk
  • Channel only
Published
Read time16 min
AuthorMainframeMaster
Verified: IBM MQ 9.3 documentation