Set the attributes of a queue
This example demonstrates how to use the MQSET call to change the attributes of a queue. This extract is taken from the Queue Attributes sample application (program CSQ4CCC1) supplied with WebSphere MQ for z/OS. For the names and locations of the sample applications on other platforms, see Sample programs (all platforms except z/OS).
#include <cmqc.h> /* MQ API header file */ ⋮ #define NUMBEROFSELECTORS 2 const MQHCONN Hconn = MQHC_DEF_HCONN; static void InhibitGetAndPut(char *Message, PMQHOBJ pHobj, char *Object) { /* */ /* Declare local variables */ /* */ MQLONG SelectorCount = NUMBEROFSELECTORS; /* Number of selectors */ MQLONG IntAttrCount = NUMBEROFSELECTORS; /* Number of int attrs */ MQLONG CharAttrLength = 0; /* Length of char attribute buffer */ MQCHAR *CharAttrs ; /* Character attribute buffer */ MQLONG SelectorsTable[NUMBEROFSELECTORS]; /* attribute selectors */ MQLONG IntAttrsTable[NUMBEROFSELECTORS]; /* integer attributes */ MQLONG CompCode; /* Completion code */ MQLONG Reason; /* Qualifying reason */ ⋮ /* */ /* Open the queue. If successful, do the */ /* inquire call. */ /* */ ⋮ /* */ /* Initialize the variables for the set call: */ /* - Set SelectorsTable to the attributes to be */ /* set */ /* - Set IntAttrsTable to the required status */ /* - All other variables are already set */ /* */ SelectorsTable[0] = MQIA_INHIBIT_GET; SelectorsTable[1] = MQIA_INHIBIT_PUT; IntAttrsTable[0] = MQQA_GET_INHIBITED; IntAttrsTable[1] = MQQA_PUT_INHIBITED; ⋮/* */ /* Issue the set call. */ /* Test the output of the set call. If the */ /* call fails, display an error message */ /* showing the completion code and reason */ /* code; otherwise move INHIBITED to the */ /* relevant screen map fields */ /* */ MQSET(Hconn, *pHobj, SelectorCount, SelectorsTable, IntAttrCount, IntAttrsTable, CharAttrLength, CharAttrs, &CompCode, &Reason); if (CompCode != MQCC_OK) { sprintf(Message, MESSAGE_4_E, ERROR_IN_MQSET, CompCode, Reason); SetMsg(Message); } else { /* Process the changes */ } /* end if CompCode */
Parent topic:
C language examples
fg18920_