HTTP DELETE: IBM MQ bridge for HTTP command

The HTTP DELETE operation gets a message from an IBM MQ queue, or retrieves a publication from a topic. The message is removed from the queue. If the publication is retained, it is not removed. A response message is sent back to the client including information about the message.


Syntax

Request

DELETEGET pathHTTP versionCRLF CRLF general-header CRLF request-header CRLF Entity-header (Request)Path / contextRoot / msg/ queue/queueName@qMgrNametopic/topicName / entity-header (Request)standard 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

HTTP version HTTP Status-Code HTTP Reason-PhraseCRLF CRLF general-header CRLF response-header CRLF Entity-header (Response)CRLFMessageentity-header (Response)standard 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


Response parameters


Description

If the HTTP DELETE 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 DELETE request is unsuccessful, the response includes an IBM MQ bridge for HTTP error message and an HTTP status code.


HTTP DELETE example

HTTP DELETE gets a message from a queue and deletes the message, or retrieves and deletes a publication. The HTTPDELETE Java sample is an example an HTTP DELETE request reading a message from a queue. Instead of using Java, you could create an HTTP DELETE request using a browser form, or an AJAX toolkit instead.

The following figure shows an HTTP request to delete the next message on queue called myQueue. In response, the message body is returned to the client. In IBM MQ terms, HTTP DELETE is a destructive get.

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 DELETE request
DELETE /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 DELETE 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 is retrieved from the queue.