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
Pathentity-header (Request) Note:- If a question mark (?) is used it must be substituted with %3f. For example, orange?topic should be specified as orange%3ftopic.
- @ qMgrName is only valid on an HTTP POST
Response
entity-header (Response)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 we 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 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.
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.