Testing communication between a client and a server

On the IBM® WebSphere® MQ MQI client workstation, use the amqsputc sample program to put a message on the queue at the server workstation. Use the amqsgetc sample program to get the message from the queue back to the client.

Before you begin

Complete the previous topics in this section:
  • Set up a queue manager, channels, and queue.
  • Open a command window.
  • Set system environment variables.

About this task

Note that IBM WebSphere MQ object definitions are case-sensitive. Text entered as an MQSC command in lowercase is converted automatically to uppercase unless you enclose it in single quotation marks. Make sure that you type the examples exactly as shown.

Procedure

  1. On UNIX and Linux® systems, change into the MQ_INSTALLATION_PATH/samp/bin directory, which contains the sample programs. For IBM WebSphere MQ client for HP Integrity NonStop Server, change into the MQ_INSTALLATION_PATH/opt/mqm/samp/bin directory, which contains the sample programs. MQ_INSTALLATION_PATH represents the high-level directory in which IBM WebSphere MQ is installed.
  2. If you are verifying an installation on a UNIX, Linux, or Windows system, you must set certain environment variables so that the installation can be used in the current shell. This step is not applicable to IBM WebSphere MQ client for HP Integrity NonStop Server. You can set the environment variables by entering one of the following commands:
    • Windows:
      MQ_INSTALLATION_PATH\bin\setmqenv -s
      where MQ_INSTALLATION_PATH refers to the location where IBM WebSphere MQ is installed.
    • UNIX and Linux:
      . MQ_INSTALLATION_PATH/bin/setmqenv -s
      where MQ_INSTALLATION_PATH refers to the location where IBM WebSphere MQ is installed.
  3. Start the PUT program for QUEUE1 on QUEUE.MANAGER.1 by entering one of the following commands:
    • Windows:
      amqsputc QUEUE1 QUEUE.MANAGER.1
    • UNIX and Linux, and IBM WebSphere MQ client for HP Integrity NonStop Server:
      ./amqsputc QUEUE1 QUEUE.MANAGER.1
    If the command is successful, the following messages are displayed:
    Sample AMQSPUT0 start target queue is QUEUE1
    Tip: You might get the error, MQRC_NOT_AUTHORIZED (2035). By default, channel authentication is enabled when a queue manager is created. Channel authentication prevents privileged users accessing a queue manager as a IBM WebSphere MQ MQI client. For verifying the installation, you can either change the MCA user ID to a non-privileged user, or disable channel authentication. To disable channel authentication run the following MQSC command:
    ALTER QMGR CHLAUTH(DISABLED)
    When you finish the test, if you do not delete the queue manager, re-enable channel authentication:
    ALTER QMGR CHLAUTH(ENABLED)
  4. Type some message text, then press Enter twice.
    The following message is displayed:
    Sample AMQSPUT0 end
    Your message is now on the queue that is on the server queue manager.
  5. Start the GET program for QUEUE1 on QUEUE.MANAGER.1 by entering one of the following commands:
    • Windows:
      amqsgetc QUEUE1 QUEUE.MANAGER.1
    • UNIX and Linux, and IBM WebSphere MQ client for HP Integrity NonStop Server:
      ./amqsgetc QUEUE1 QUEUE.MANAGER.1
    The sample program starts, and your message is displayed. After a short pause (approximately 30 seconds), the sample ends and the command prompt is displayed again.

Results

You have now successfully verified the client installation.

What to do next

  1. If your server is a Windows, UNIX, or Linux system, you must set various environment variables so that the installation can be used in the current shell. You can set the environment variables by entering one of the following commands:
    • Windows:
      MQ_INSTALLATION_PATH\bin\setmqenv -s
      where MQ_INSTALLATION_PATH refers to the location where IBM WebSphere MQ is installed.
    • UNIX and Linux systems:
      . MQ_INSTALLATION_PATH/bin/setmqenv -s
      where MQ_INSTALLATION_PATH refers to the location where IBM WebSphere MQ is installed.
  2. On the server, stop the queue manager by entering the following command:
    endmqm QUEUE.MANAGER.1
  3. On the server, delete the queue manager by entering the following command:
    dltmqm QUEUE.MANAGER.1