MQCLOSE: Close an object

This function closes a process, queue, or queue manager.

Last updated

  • Changed for PUT11.
  • Changed for PUT00.

Format

LIBS := see programming considerations 
#include  <tpf/cmqc.h>
void      MQCLOSE(MQHCONN Hconn,
                  PMQHOBJ pHobj,
                  MQLONG  Options,
                  PMQLONG pCompCode,
                  PMQLONG pReason);
Hconn
The connection handle, which represents the connection to the z/TPF MQSeries® queue manager. The value of Hconn was returned by a previous MQCONN call.
pHobj
A pointer to the location to store the handle, which represents the process, queue, or queue manager. The value of Hobj was returned by a previous MQOPEN call.
Options
The options that control the action of MQCLOSE. z/TPF MQSeries queue manager ignores this parameter.
pCompCode
A pointer to the location to store the completion code, which is one of the following:
MQCC_OK
Successfully completed.
MQCC_FAILED
The call failed.
pReason
A pointer to the location to store the reason code that qualifies the completion code.

If the completion code is MQCC_OK, the reason code is MQRC_NONE, which indicates a normal return.

If the completion code is MQCC_FAILED, see Error return for the corresponding reason codes.

Normal return

MQCC_OK
Completion code completed successfully.
MQRC_NONE
Reason code completed successfully.

Error return

If the completion code is MQCC_FAILED, the function failed with one of the following reason codes:
MQRC_HCONN_ERROR
The connection handle is not valid.
MQRC_HOBJ_ERROR
The object handle is not valid.
MQRC_Q_MGR_NOT_ACTIVE
The z/TPF MQSeries queue manager is not started.
MQRC_Q_MGR_NOT_AVAILABLE
The z/TPF MQSeries queue manager is not loaded.

Programming considerations

  • The library that is required to use this function is determined by the following situations:
    • If the application will exclusively access a remote queue manager rather than the local z/TPF IBM® MQ queue manager, you can include the CMQI library in the makefile and add the -D_TPF_CLIENTONLY option to the CFLAGS_PGMX or CXXFLAGS_PGMY statement to improve the application performance.
    • If the queue manager that the application will access is not known, or if the application is accessing the local z/TPF IBM MQ queue manager, you must include the CMQS library in the makefile and not add the -D_TPF_CLIENTONLY option to the CFLAGS_PGMX or CXXFLAGS_PGMY statement.
  • If the Hconn parameter is not for the local z/TPF MQSeries queue manager, this MQCLOSE function call will be sent by z/TPF MQSeries client support to the remote queue manager for processing. The options supported by the remote queue manager can differ from the options specified for the local z/TPF MQSeries queue manager.

Examples

The following example closes a queue.
#include <tpf/cmqc.h>

PMQHOBJ pHobj;
MQLONG  CompCode;                        /* completion code        */
MQLONG  Reason;                          /* reason code            */
MQHCONN Hcon;                            /* Connection Handle      */
MQLONG  C_options = 0;

/* Hcon and Hobj from previous MQCONN MQOPEN                       */
MQCLOSE(Hcon, pHobj, C_options, &CompCode, &Reason);

if(Reason != MQRC_NONE)
   printf("MQCLOSE ended with reason code %d.\n",Reason);