Commit is the moment IBM MQ makes your unit of work real. Until MQCMIT—or CICS SYNCPOINT on mainframe tasks—syncpointed puts are hidden and syncpointed gets are held in limbo. Application designers choose commit points deliberately: after database insert succeeds, after all three queues receive related messages, after validation passes. Commit too early and bad data is permanent; commit too late and queues block under uncommitted gets. This tutorial explains MQCMIT usage, what becomes visible after commit, interaction with persistence, commit in CICS and Java EE containers, one-phase versus two-phase in XA overview, failure and indoubt handling pointers, and patterns for batch commit frequency.
After MQPUT and MQGET calls with SYNCPOINT options, MQCMIT(Hconn, &compCode, &reason) ends the UOW successfully. Completion code OK means the commit request was processed; always check reason on edge cases. A new UOW starts for subsequent syncpoint operations. Programs that forget MQCMIT leave messages invisible and holds locks until disconnect rollback.
1234567/* After successful processing */ MQCMIT(Hconn, &compCode, &reason); if (compCode != MQCC_OK) { /* handle commit failure - UOW may be in doubt */ } /* Next put/get starts new UOW if syncpoint used */
| Prior operation | After commit |
|---|---|
| MQPUT + MQPMO_SYNCPOINT | Message available on queue |
| MQGET + MQGMO_SYNCPOINT | Message removed for others |
| MQPUT + NO_SYNCPOINT | Already committed at put time |
| MQBACK before commit | N/A — UOW undone |
Commit is licking the stamp and dropping the letter in the outbound bin. Until then, the letter sat on the clerk desk (provisional UOW).
Order matters when mixing DB and MQ: coordinated XA commits both together; non-coordinated designs pick risk of message loss versus duplicate explicitly.
EXEC CICS SYNCPOINT without ROLLBACK commits MQ and other recoverable resources in the task. Nested syncpoints follow CICS rules. Application developers may never call MQCMIT directly—the task end or SYNCPOINT command drives commit. Understand task design to avoid long tasks holding uncommitted gets.
JMS session commit() or container @Transactional boundary commit may map to MQCMIT under the hood. Let the container drive commit unless you use bean-managed transactions. Mixing manual MQCMIT with container boundaries causes double-commit or rollback confusion.
Processing ten thousand messages: commit every message is safe but slow; commit every thousand balances recovery granularity with throughput. On failure, at most 999 messages may reprocess—ensure idempotency. Tune with performance tests, not guesses.
Network partition during commit can leave transaction indoubt—especially in XA. DISPLAY transaction and recovery tools resolve heuristics. Operations runbacks per IBM recovery guide. Applications should log reason codes and not assume silent success.
Commit makes syncpoint work visible; persistence determines restart survival. Committed non-persistent message can still be lost on power failure. Committed persistent message survives with logged media.
Commit is pressing save on your video game so your coins stay saved when you turn off the TV.
Write pseudocode for get-process-commit with exception path to MQBACK.
Compare commit-every-message versus commit-every-100 for a 50k backlog consumer.
When does CICS commit MQ without the program calling MQCMIT?
1. MQCMIT makes:
2. After commit, syncpointed put:
3. CICS SYNCPOINT commits:
4. Commit applies to: