HTTP GET: IBM MQ bridge for HTTP command

The HTTP GET operation gets a message from an IBM® MQ queue. The message remains on the queue. The HTTP GET operation is equivalent to browsing an IBM MQ queue.

Syntax

Request

Read syntax diagramSkip visual syntax diagram DELETEGET pathHTTP versionCRLF CRLF general-header CRLF request-header CRLF Entity-header (Request)
Path
Read syntax diagramSkip visual syntax diagram / contextRoot / msg/ queue/queueName@qMgrNametopic/topicName /
entity-header (Request)
Read syntax diagramSkip visual syntax diagramstandard entity-header entity-valuex-msg-correlId correlation IDx-msg-msgId message IDx-msg-range rangex-msg-require-headers entity header namex-msg-wait wait time
Note:
  1. If a question mark (?) is used it must be substituted with %3f. For example, orange?topic should be specified as orange%3ftopic.
  2. @ qMgrName is only valid on an HTTP POST

Response

Read syntax diagramSkip visual syntax diagramHTTP version HTTP Status-Code HTTP Reason-PhraseCRLF CRLF general-header CRLF response-header CRLF Entity-header (Response)CRLFMessage
entity-header (Response)
Read syntax diagramSkip visual syntax diagramstandard entity-header entity-valuex-msg-class message typex-msg-correlId correlation IDx-msg-encoding encoding typex-msg-expiry durationx-msg-format message formatx-msg-msgId message IDx-msg-persistence persistencex-msg-priority priority classx-msg-replyTo reply-to queuex-msg-timestamp HTTP-datex-msg-usr user properties

Request parameters

Path
See URI Format.
HTTP version
HTTP version; for example, HTTP/1.1
general-header
See HTTP/1.1 - 4.5 General Header Fields.
request-header
See HTTP/1.1 - 5.3 Request Header Fields. The Host field is mandatory on an HTTP/1.1 request. It is often automatically inserted by the tool you use to create a client request.
entity-header (Request)
See HTTP/1.1 - 7.1 Entity Header Fields. One of the entity headers listed in the Request syntax diagram.

Response parameters

Path
See URI Format.
HTTP version
HTTP version; for example, HTTP/1.1
general-header
See HTTP/1.1 - 4.5 General Header Fields.
response-header
See HTTP/1.1 - 6.2 Response Header Fields.
entity-header (Response)
See HTTP/1.1 - 7.1 Entity Header Fields. One of the entity or response headers listed in the Response syntax diagram. The Content-Length is always present in a response. It is set to zero if there is no message body.
Message
Message body.

Description

If the HTTP GET request is successful, the response message contains the data retrieved from the IBM MQ queue. The number of bytes in the body of the message is returned in the HTTP Content-Length header. The status code for the HTTP response is set to 200 OK. If x-msg-range is specified as 0, or 0-0, then the status code of the HTTP response is 204 No Content.

If the HTTP GET request is unsuccessful, the response includes an IBM MQ bridge for HTTP error message and an HTTP status code.

HTTP GET example

HTTP GET gets a message from a queue. The message remains on the queue. In IBM MQ terms, HTTP GET is a browse request. You could create an HTTP GET request using a Java client, a browser form, or an AJAX toolkit.

The following figure shows an HTTP request to browse the next message on queue called myQueue.

The request contains the HTTP request header x-msg-wait, which instructs IBM MQ bridge for HTTP how long to wait for a message to arrive on the queue. The request also contains the x-msg-require-headers request header, which specifies that the client is to receive the message correlation ID in the response.

Figure 1. Example of an HTTP GET request

GET /msg/queue/myQueue/ HTTP/1.1
Host: www.example.org
x-msg-wait: 10
x-msg-require-headers: correlID

The following figure shows the response returned to the client. The correlation ID is returned to the client, as requested in x-msg-require-headers of the request.

Figure 2. Example of an HTTP GET response

HTTP/1.1 200 OK
Date: Wed, 2 Jan 2007 22:38:34 GMT
Server: Apache-Coyote/1.1 WMQ-HTTP/1.1 JEE-Bridge/1.1
Content-Length: 50
Content-Type: text/plain; charset=utf-8
x-msg-correlId: 1234567890

Here is my message body that appears on the queue.