The Connect sample program
The Connect sample program allows you to explore the MQCONNX call and its options from a client. The sample connects to the queue manager using the MQCONNX call, inquires about the name of the queue manager using the MQINQ call, and displays it. Also, learn about running the amqscnxc sample.
Note: The Connect sample program is a client sample. We can compile and run it on a server but the function is meaningful only on a client, and only client-executable files are supplied.
Running the amqscnxc sample
The command-line syntax of the Connect sample program is:amqscnxc [-x ConnName [-c SvrconnChannelName]] [-u User] [QMgrName]The parameters are optional and their order is not important except for QMgrName, which, if specified, must come last. The parameters are:
- ConnName
- The TCP/IP connection name of the server queue manager
If we do not specify the TCP/IP connection name, MQCONNX is issued with the ClientConnPtr set to NULL.
- SvrconnChannelName
- The name of the server connection channel
If you specify the TCP/IP connection name but not the server connection channel (the reverse is not allowed), the sample uses the name SYSTEM.DEF.SVRCONN.
- User
- The user name to be used for connection authentication
If you specify this the program will prompt for a password to accompany that user ID.
- QMgrName
- The name of the target queue manager
If we do not specify the target queue manager, the sample connects to whichever queue manager is listening at the given TCP/IP connection name.
Note: If you enter a question mark as the only parameter, or if you enter incorrect parameters, you get a message explaining how to use the program. If you run the sample with no command-line options, the contents of the MQSERVER environment variable are used to determine the connection information. (In this example MQSERVER is set to SYSTEM.DEF.SVRCONN/TCP/machine.site.company.com.) You see output like this:
Sample AMQSCNXC start Connecting to the default queue manager with no client connection information specified. Connection established to queue manager machine Sample AMQSCNXC endIf you run the sample and provide a TCP/IP connection name and a server connection channel name but no target queue manager name, like this:amqscnxc -x machine.site.company.com -c SYSTEM.ADMIN.SVRCONNthe default queue manager name is used and you see output like this:Sample AMQSCNXC start Connecting to the default queue manager using the server connection channel SYSTEM.ADMIN.SVRCONN on connection name machine.site.company.com. Connection established to queue manager MACHINE Sample AMQSCNXC endIf you run the sample and provide a TCP/IP connection name and a target queue manager name, like this:amqscnxc -x machine.site.company.com MACHINEyou see output like this:Sample AMQSCNXC start Connecting to queue manager MACHINE using the server connection channel SYSTEM.DEF.SVRCONN on connection name machine.site.company.com. Connection established to queue manager MACHINE Sample AMQSCNXC endParent topic: Use the sample programs on Multiplatforms