The PeekMessage action returns a preview of the message specified by the MessageId parameter. The message is returned regardless of the VisibilityTimeout state on the queue. The visibility state is not modified when PeekMessage is used, thereby not affecting which messages get returned from a subsequent ReceiveMessage request.
A PeekMessage request is validated on the following:
The queue specified must exist. The URL to the queue must have been returned from a CreateQueue or ListQueues request.
MessageId must exist and be a value returned by a ReceiveMessage or SendMessage request.
Returns Success, the message body, and the message ID of the message specified if successful. It returns an error response if unsuccessful.
| Name | Description | Type | Value |
|---|---|---|---|
MessageId
| Required. The message ID of the message to return. | String | 17VXQHSGX0SG4ZEPPK7R|0QE42ST4KW7RK9HSY074|0Z4AN912X0H2EP8BV6XJ |
The following example PeekMessage request returns the message associated with the message ID specified.
<soap:Body wsu:Id="body"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<m:PeekMessage xmlns:m="http://queue.amazonaws.com/doc/2006-04-01/">
<m:MessageId>
<m:MessageId>
17VXQHSGX0SG4ZEPPK7R%7C0QE42ST4KW7RK9HSY074%7C0Z4AN912X0H2EP8BV6XJ
</m:MessageId>
</m:MessageId>
</m:PeekMessage>
</soap:Body>
<PeekMessageResponse>
<Message>
<MessageId>
17VXQHSGX0SG4ZEPPK7R|0QE42ST4KW7RK9HSY074|0Z4AN912X0H2EP8BV6XJ
</MessageId>
<MessageBody>foo</MessageBody>
</Message>
<ResponseStatus>
<StatusCode>Success</StatusCode>
<RequestId>cb919c0a-9bce-4afe-9b48-9bdf2412bb67</RequestId>
</ResponseStatus>
</PeekMessageResponse>