gtpc2m4x | C/C++ Language Support User's Guide |
This function connects an application program to a message queuing queue
manager. This function provides a queue manager connection handle,
which is used by the application on subsequent message queuing calls.
Format
#include <cmqc.h>
void MQCONN(PMQCHAR pName,
PMQHCONN pHconn,
PMQLONG pCompCode,
PMQLONG pReason);
- pName
- A pointer to the name of a queue manager. If the name consists
entirely of blanks, the name of the local TPF MQSeries queue manager is
used. If the name does not consist entirely of blanks and is not the
name of the local TPF MQSeries queue manager (as defined in the ZMQSC DEF MQP
command), the application is connected to a remote queue manager by TPF
MQSeries client support.
- pHconn
- A pointer to the location to store the connection handle, which represents
the connection to the TPF MQSeries queue manager. You must specify the
connection handle on all subsequent message queueing calls issued by the
application.
- 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.
See MQSeries Application Programming Reference
and MQSeries Message Queue Interface Technical
Reference for more information about MQSeries data types and
parameters.
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_Q_MGR_NOT_AVAILABLE
- The queue manager is not available.
- MQRC_Q_MGR_NAME_ERROR
- The queue manager name is not valid.
- MQRC_Q_MGR_NOT_ACTIVE
- The queue manager is not started.
- MQRC_Q_MGR_STOPPING
- The queue manager is stopping.
Programming Considerations
- If the application connects to a remote queue manager (not the local TPF
MQSeries queue manager), only the MQCONN function, as described in
the MQSeries Application Programming Guide, can be
used.
- If the application connects to the local TPF MQSeries queue manager, only
the MQCONN function, as described in this publication, TPF C/C++ Language Support User's Guide, can be
used.
- Use the MQDISC function to disconnect from the TPF MQSeries
queue manager.
Examples
The following example connects an application program to the local TPF
MQSeries queue manager.
#include <cmqc.h>
MQLONG CompCode; /* completion code */
MQLONG Reason; /* reason code */
MQHCONN Hcon = MQHC_UNUSABLE_HCONN; /* Connection Handle */
CHAR QMngrName [] = "TPF.QMGR";
/*********************************************/
/*CONNECT TO QUEUE MANAGER */
/*********************************************/
MQCONN(QMngrName, &Hcon, &CompCode, &Reason);
if(CompCode == MQCC_FAILED)
{
printf("MQCONN ended with the reason code %d.\n", Reason);
exit(Reason);
}
·
·
·
Related Information