Commit

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.

MQCMIT in MQI

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.

c
1
2
3
4
5
6
7
/* 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 */
Effects of successful commit
Prior operationAfter commit
MQPUT + MQPMO_SYNCPOINTMessage available on queue
MQGET + MQGMO_SYNCPOINTMessage removed for others
MQPUT + NO_SYNCPOINTAlready committed at put time
MQBACK before commitN/A — UOW undone

Explainer: Sealing the Envelope

Commit is licking the stamp and dropping the letter in the outbound bin. Until then, the letter sat on the clerk desk (provisional UOW).

Consumer Commit Pattern

  1. MQGET with MQGMO_SYNCPOINT.
  2. Parse and validate payload.
  3. Update database or call service.
  4. On success: MQCMIT (message consumption final).
  5. On failure: MQBACK (message returns, retry possible).

Order matters when mixing DB and MQ: coordinated XA commits both together; non-coordinated designs pick risk of message loss versus duplicate explicitly.

CICS SYNCPOINT

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.

Java and Container-Managed Transactions

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.

Batch Commit Frequency

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.

Commit Failure and Indoubt

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.

Persistence Interaction

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.

Explain Like I'm Five: Commit

Commit is pressing save on your video game so your coins stay saved when you turn off the TV.

Practice Exercises

Exercise 1

Write pseudocode for get-process-commit with exception path to MQBACK.

Exercise 2

Compare commit-every-message versus commit-every-100 for a 50k backlog consumer.

Exercise 3

When does CICS commit MQ without the program calling MQCMIT?

Frequently Asked Questions

Frequently Asked Questions

Test Your Knowledge

Test Your Knowledge

1. MQCMIT makes:

  • Current UOW permanent
  • Queue manager stop
  • Channel delete
  • Format disk

2. After commit, syncpointed put:

  • Visible to getters
  • Always deleted
  • Never logged
  • Goes to DLQ

3. CICS SYNCPOINT commits:

  • Task UOW including MQ
  • Only VSAM
  • Only JCL
  • Only TCP

4. Commit applies to:

  • Whole current UOW
  • One selected message
  • One channel
  • One listener
Published
Read time18 min
AuthorMainframeMaster
Verified: IBM MQ 9.3 documentation