DEFINE is the MQSC verb that creates IBM MQ objects in the queue manager repository. When you type DEFINE QLOCAL('PAYMENTS.IN') in runmqsc, the command server validates the object type, name, and attributes, then stores the definition on disk so the queue manager can honor MQOPEN from applications. DEFINE does not move business data—it only declares that a named queue, channel, listener, or topic exists with specific properties. Every environment built through infrastructure-as-code depends on repeatable DEFINE scripts checked into Git. This tutorial explains DEFINE syntax, the most common object types, essential attributes beginners must understand, REPLACE for promotion pipelines, typical AMQ errors, verification with DISPLAY, and how DEFINE relates to ALTER and DELETE in the object lifecycle.
The general form is DEFINE object_type('object_name') attribute(value) attribute(value). Object names are usually uppercase by convention but MQ accepts mixed case in quotes. String attributes use single quotes. Numeric attributes use integers without quotes. Multiple lines continue with + at end of line. Each command ends with a semicolon. The command server responds with one or more lines per command, including AMQ8006I display-style confirmations or AMQ error codes when validation fails.
1234567891011DEFINE QLOCAL('ORDERS.IN') REPLACE + DESCR('Inbound order work queue') + MAXDEPTH(100000) MAXMSGL(4194304) + DEFPSIST(YES) BOTHRESH(5) + BOQNAME('ORDERS.DLQ') GET(ENABLED) PUT(ENABLED) * REPLACE — create or overwrite definition (DevOps friendly) * MAXDEPTH — max messages; PUT fails with 2053 when full * MAXMSGL — max bytes per message * DEFPSIST(YES) — default new messages persistent * BOTHRESH — backouts before message to BOQNAME * BOQNAME — dead-letter queue for poison messages
QLOCAL is the workhorse queue type. Applications PUT and GET here; messages are stored on this queue manager until consumed. MAXDEPTH caps backlog—critical for capacity. MAXMSGL must exceed your largest expected payload. DEFPSIST sets default persistence for messages unless the put overrides it. GET and PUT ENABLED allow applications to open for input or output; DISABLE is used for maintenance queues. SHARE determines whether multiple applications can open simultaneously. DEFBIND and CLUSTER matter when the queue participates in a cluster. Beginners should define a DLQ first, then work queues with BOQNAME pointing to it.
| DEFINE type | Creates | Typical next step |
|---|---|---|
| QLOCAL | Application queue | setmqaut, app deploy |
| QREMOTE | Route to remote queue | DEFINE channel + XMITQ |
| QALIAS | Alternate name | Point to QLOCAL or QREMOTE |
| CHANNEL | Channel definition | START CHANNEL |
| LISTENER | TCP listener | START LISTENER |
| TOPIC | Pub/sub topic | DEFINE SUB |
DEFINE CHANNEL creates a channel definition, not an active TCP session. You must specify CHLTYPE: SDR (sender), RCVR (receiver), SVRCONN (client connection), CLNTCONN, CLUSSDR, CLUSRCVR, and others per IBM documentation. Sender channels need XMITQ naming the transmission queue. Receiver channels pair with a LISTENER on a port. SVRCONN channels need MCAUSER and often SSL parameters for production. After DEFINE, START CHANNEL initiates the connection for message channels. Wrong CHLTYPE is a frequent exam and interview mistake—same channel name on both sides but different types.
123456DEFINE CHANNEL('HUB.TO.BRANCH') CHLTYPE(SDR) TRPTYPE(TCP) + CONNAME('branch.example.com(1414)') XMITQ('SYSTEM.DEAD.LETTER.QUEUE') + REPLACE DEFINE CHANNEL('HUB.TO.BRANCH') CHLTYPE(RCVR) TRPTYPE(TCP) REPLACE * SDR — outbound; needs CONNAME and XMITQ on sending QM * RCVR — inbound; partner SDR connects to your listener
LISTENER defines the TCP port that accepts inbound connections—PORT(1414) is the classic example. CONTROL(QMGR) ties listener lifecycle to queue manager start in many estates. TOPIC defines a node in the topic tree with TOPICSTR for the string hierarchy. SUB creates a subscription routing matching publications to DEST subscriber queue. PROCESS supports triggering—application name and parameters when a trigger fires. Each object type has mandatory and optional attributes; IBM Knowledge Center lists valid combinations per MQ version.
REPLACE is the most important modifier for automation. Without it, a second run of your script fails. Some teams use DEFINE like('TEMPLATE.QUEUE') for QLOCAL to copy attributes from an existing queue—useful for standardizing hundreds of queues from one gold copy. Verify the template queue exists and is audited before cloning security-sensitive attributes.
DEFINE is the architect's blueprint: it says there will be a mailbox named ORDERS.IN with a maximum pile height (MAXDEPTH) and whether letters must be filed permanently (DEFPSIST). Workers (applications) only use the mailbox after the blueprint is approved and registered with the building (queue manager).
DEFINE is telling the mail building to add a new mailbox with rules: how big it can get, whether letters stay even if the building restarts, and where broken letters go.
Write a script defining DLQ, work queue, and SDR/RCVR pair with REPLACE.
Intentionally omit MAXDEPTH; document platform default with DISPLAY.
List five attributes you would never copy blindly from a template without review.
1. DEFINE creates:
2. REPLACE on DEFINE allows:
3. DEFINE CHANNEL creates:
4. After DEFINE QLOCAL verify with: