Running the IBM MQ bridge for HTTP samples

The IBM MQ bridge for HTTP samples are available for use on only the Windows operating system. The samples show you how to submit HTTP POST and HTTP DELETE commands to IBM MQ bridge for HTTP from Java programs.


Before you begin

Verify your IBM MQ bridge for HTTP installation by running step 7 in Install, configuring, and verifying IBM MQ bridge for HTTP.

The HTTP samples are installed to the directories shown in Table 1. In each case, source code is installed to the /src subdirectory.
Table 1. Location of HTTP samples
Platform Location
Windows MQ_INSTALLATION_PATH/tools/http/samples
z/OSĀ® PathPrefix/usr/lpp/mqm/V7R0M0/http/samples
IBM i MQ_INSTALLATION_PATH/java/samples/http
All other platforms MQ_INSTALLATION_PATH/samp/http
MQ_INSTALLATION_PATH represents the directory where IBM MQ is installed.


About this task

The samples simulate the IBM MQ AMQSPUT and AMQSGET sample applications. They illustrate the following functions in a point-to-point messaging environment:

  • HTTPPOST - Sends HTTP POST requests in a Java application to put messages to an IBM MQ queue, using the IBM MQ bridge for HTTP and handles the responses.
  • HTTPDELETE - Sends HTTP DELETE requests in a Java application to get messages from an IBM MQ queue, using the IBM MQ bridge for HTTP and handles the responses containing the IBM MQ message.

Parameters for HTTPPOST and HTTPDELETE

SYSTEM.DEFAULT.LOCAL.QUEUEqueueName
  • localhost:8080hostName
  • mqcontextRoot
  • To run the HTTPPOST sample, complete the following steps:


    Procedure

    1. In a command window, navigate to the HTTP samples directory.
    2. Run the HTTPPOST sample.
      java -classpath . HTTPPOST [parameters]
      
      When the HTTPPOST sample starts, the following output is displayed:
      HTTP POST Sample start
      Target server is ' hostName '
      Target queue is ' queueName '
      Target context-root is ' contextRoot '
    3. In the command prompt, type the text to form your message body.
    4. Press Enter to post the message to the IBM MQ queue.
      1. If you want to send another message, enter some more text. The text forms the body of a second IBM MQ message.
      2. Press Enter to post the message to the IBM MQ queue.
    5. Press Enter twice to end HTTPPOST. The following output is displayed:
      HTTP POST Sample end
      


    What to do next

    The HTTPDELETE sample performs a destructive get of all the messages you placed on the IBM MQ queue.

    Run the HTTPDELETE sample by completing the following steps:

    1. In a command window, navigate to MQ_INSTALLATION_PATH/tools/samples. MQ_INSTALLATION_PATH represents the directory where IBM MQ is installed.
    2. Run the HTTPDELETE sample.
      java -classpath . HTTPPOST [parameters]
      
      When the HTTPDELETE sample starts, the following output is displayed:
      HTTP DELETE Sample start
      Target server is ' host:port '
      Target queue is ' your queue name '
      Target context-root is ' your context-root '
      message
      message
      ...