Working with model queues

A queue manager creates a dynamic queue if it receives an MQI call from an application specifying a queue name that has been defined as a model queue. The name of the new dynamic queue is generated by the queue manager when the queue is created. A model queue is a template that specifies the attributes of any dynamic queues created from it. Model queues provide a convenient method for applications to create queues as required.


Defining a model queue

We use the DEFINE QMODEL command to define a model queue with a set of attributes in the same way that you define a local queue. Model queues and local queues have the same set of attributes, except that on model queues we can specify whether the dynamic queues created are temporary or permanent. (Permanent queues are maintained across queue manager restarts, temporary ones are not.) For example:
DEFINE QMODEL (GREEN.MODEL.QUEUE) +
DESCR('Queue for messages from application X') +
PUT (DISABLED) +
GET (ENABLED) +
NOTRIGGER +
MSGDLVSQ (FIFO) +
MAXDEPTH (1000) +
MAXMSGL (2000) +
USAGE (NORMAL) +
DEFTYPE (PERMDYN)

This command creates a model queue definition. From the DEFTYPE attribute, we can see that the actual queues created from this template are permanent dynamic queues. Any attributes not specified are automatically copied from the SYSYTEM.DEFAULT.MODEL.QUEUE default queue.

We can use the LIKE and REPLACE attributes when you define model queues, in the same way that we use them with local queues.


Use other commands with model queues

We can use the appropriate MQSC commands to display or alter a model queue's attributes, or to delete the model queue object. For example:

Use the DISPLAY QUEUE command to display the model queue's attributes:
DISPLAY QUEUE (GREEN.MODEL.QUEUE)

Use the ALTER QMODEL command to alter the model to enable puts on any dynamic queue created from this model:

ALTER QMODEL (BLUE.MODEL.QUEUE) PUT(ENABLED)

Use the DELETE QMODEL command to delete this model queue:

DELETE QMODEL (RED.MODEL.QUEUE)