Calling ‘MQINQ’ in COBOL to Get Queue Details See How

Here’s an example of COBOL to get queue details using MQINQ. MQ-series is IBM middle-ware product that helps integrate heterogeneous interfaces. Don’t worry. I’ll help you with how to use this and show you how to use this.

Advertisements

What are Queue Attributes?

MQINQ provides queue attributes. The below table tells you the list of attributes of a Queue.

AttributeData TypeDescription
ALTERATION_DATECharacter12Date definition last changed
ALTERATION_TIMECharacter8Time definition was last changed
BACKOUT_REQ_Q_NAMECharacter48Excessive backout requeue name
BACKOUT_THRESHOLDNumericBackout threshold
BASE_Q_NAMECharacter48Name of queue to which alias resolves
CF_STRUC_NAMECharacter12Coupling-facility structure name (z/OS only)
CLUSTER_NAMECharacter48Name of cluster to which queue belongs
CLUSTER_NAMELISTCharacter48Name of namelist containing names of clusters to which queue belongs
CLUSTER_WORKLOAD_DATACharacter32User data for cluster workload exit
CLUSTER_WORKLOAD_LENGTHNumericMaximum length of message data passed to cluster workload exit
CREATION_DATECharacter12Queue creation date
CREATION_TIMECharacter8Queue creation time
CURRENT_Q_DEPTHNumericNumber of messages on queue
DEF_BINDNumericDefault binding
DEF_INPUT_OPEN_OPTIONNumericDefault open-for-input option
DEF_PERSISTENCENumericDefault message persistence
DEF_PRIORITYNumericDefault message priority
DEF_XMIT_Q_NAMECharacter48Default transmission queue name
DEFINITION_TYPENumericQueue definition type
EXPIRY_INTERVALNumericInterval between scans for expired messages (z/OS only)
HARDEN_GET_BACKOUTNumericWhether to harden backout count
IGQ_PUT_AUTHORITYNumericIntra-group queuing put authority (z/OS only)
IGQ_USER_IDCharacter12Intra-group queuing agent user ID (z/OS only)
INDEX_TYPENumericIndex type (z/OS only)
INHIBIT_GETNumericWhether get operations are allowedThis output type is not supported on z/OS.
INHIBIT_PUTNumericWhether put operations are allowed
INITIATION_Q_NAMECharacter48Initiation queue name
INTRA_GROUP_QUEUINGNumericIntra-group queuing support (z/OS only)
MAX_MSG_LENGTHNumericMaximum message length
MAX_Q_DEPTHNumericMaximum number of messages allowed on queue
MSG_DELIVERY_SEQUENCENumericWhether message priority is relevant
OPEN_INPUT_COUNTNumericNumber of CALL MQOPEN routines that have the queue open for input
OPEN_OUTPUT_COUNTNumericNumber of CALL MQOPEN routines that have the queue open for output
PROCESS_NAMECharacter32Name of process definition
Q_DEPTH_HIGH_EVENTNumericControl attribute for queue depth high eventsThis output type is not supported on z/OS.
Q_DEPTH_HIGH_LIMITNumericHigh limit for queue depthThis output type is not supported on z/OS.
Q_DEPTH_LOW_EVENTNumericControl attribute for queue depth low eventsThis output type is not supported on z/OS.
Q_DEPTH_LOW_LIMITNumericLow limit for queue depthThis output type is not supported on z/OS.
Q_DEPTH_MAX_EVENTNumericControl attribute for queue depth max eventsThis output type is not supported on z/OS.
Q_DESCCharacter64Queue description
Q_NAMECharacter48Queue name
Q_SERVICE_INTERVALNumericLimit for queue service intervalThis output type is not supported on z/OS.
Q_SERVICE_INTERVAL_EVENTNumericControl for queue service interval eventsThis output type is not supported on z/OS.
Q_TYPENumericQueue type
QSG_DISPNumericQueue-sharing group disposition (z/OS only)
QSG_NAMECharacter4Name of queue-sharing group (z/OS only)
REMOTE_Q_MGR_NAMECharacter48Name of remote queue manager
REMOTE_Q_NAMECharacter48Name of remote queue as known on remote queue manager
RETENTION_INTERVALNumericQueue retention interval
SCOPENumericQueue definition scopeThis output type is not supported on z/OS.
SHAREABILITYNumericWhether queue can be shared
STORAGE_CLASSCharacter8Storage class for queue (z/OS only)
TRIGGER_CONTROLNumericTrigger control
TRIGGER_DATACharacter64Trigger data
TRIGGER_DEPTHNumericTrigger depth
TRIGGER_MSG_PRIORITYNumericThreshold message priority for triggers
TRIGGER_TYPENumericTrigger type
USAGENumericUsage
XMIT_Q_NAMECharacter48Default transmission queue name

In total, attributes of four objects you’ll get when you call MQINQ. Below is the list (Queues, Namelists, Process definitions, and Queue Manager).

  • Table 1 MQINQ attribute selectors for queues
  • Table 2 MQINQ attribute selectors for namelists
  • Table 3 MQINQ attribute selectors for process definitions
  • Table 4 MQINQ attribute selectors for the queue manager

How to Get Queue Depth? (Number of Messages in a Queue)

First, you need to make MQINQ standard call. If successful, you will get queue attributes. Here’s more on MQINQ.

COBOL Sample Logic to CALL MQINQ

If this call is successful, you’ll get queue attributes.

*
* Inquire about the attributes.
*
CALL 'MQINQ' USING W02-HCONN,
W02-HOBJ,
W02-SELECTORCOUNT,
W02-SELECTORS-TABLE, /* Here stores all the info*/
W02-INTATTRCOUNT,
W02-INTATTRS-TABLE,
W02-CHARATTRLENGTH,
W02-CHARATTRS,
W02-COMPCODE,
W02-REASON.
*
* Test the output from the inquiry:
*
* - If the completion code is not OK, display an error
* message showing the completion and reason codes
*
* - Otherwise, move the correct attribute status into
* the relevant screen map fields
*
IF W02-COMPCODE NOT = MQCC-OK
MOVE 'MQINQ' TO M01-MSG4-OPERATION
MOVE W02-COMPCODE TO M01-MSG4-COMPCODE
MOVE W02-REASON TO M01-MSG4-REASON
MOVE M01-MESSAGE-4 TO M00-MESSAGE
*
ELSE
* Process the changes.

END-IF.

After executing the above logic, you’ll get data into the selectors-Table. From it, you can get the ‘Q depth’ value, which ( CURRENT_Q_DEPTH ) tells the number of messages in a Queue.

References

Related Posts

Get new content delivered directly to your inbox.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.