public class ReceiveMessageRequest extends AmazonWebServiceRequest implements Serializable, Cloneable
ReceiveMessage operation
.
Retrieves one or more messages, with a maximum limit of 10 messages,
from the specified queue. Long poll support is enabled by using the
WaitTimeSeconds
parameter. For more information, see
Amazon SQS Long Poll
in the Amazon SQS Developer Guide .
Short poll is the default behavior where a weighted random set of
machines is sampled on a ReceiveMessage
call. This means
only the messages on the sampled machines are returned. If the number
of messages in the queue is small (less than 1000), it is likely you
will get fewer messages than you requested per
ReceiveMessage
call. If the number of messages in the
queue is extremely small, you might not receive any messages in a
particular ReceiveMessage
response; in which case you
should repeat the request.
For each message returned, the response includes the following:
Message body
MD5 digest of the message body. For information about MD5, go to http://www.faqs.org/rfcs/rfc1321.html .
Message ID you received when you sent the message to the queue.
Receipt handle.
Message attributes.
MD5 digest of the message attributes.
The receipt handle is the identifier you must provide when deleting the message. For more information, see Queue and Message Identifiers in the Amazon SQS Developer Guide .
You can provide the VisibilityTimeout
parameter in your
request, which will be applied to the messages that Amazon SQS returns
in the response. If you do not include the parameter, the overall
visibility timeout for the queue is used for the returned messages.
For more information, see
Visibility Timeout
in the Amazon SQS Developer Guide .
NOTE: Going forward, new attributes might be added. If you are writing code that calls this action, we recommend that you structure your code so that it can handle new attributes gracefully.
NOOP
Constructor and Description |
---|
ReceiveMessageRequest()
Default constructor for a new ReceiveMessageRequest object.
|
ReceiveMessageRequest(String queueUrl)
Constructs a new ReceiveMessageRequest object.
|
Modifier and Type | Method and Description |
---|---|
ReceiveMessageRequest |
clone() |
boolean |
equals(Object obj) |
List<String> |
getAttributeNames()
A list of attributes that need to be returned along with each message.
|
Integer |
getMaxNumberOfMessages()
The maximum number of messages to return.
|
List<String> |
getMessageAttributeNames()
The name of the message attribute, where N is the index.
|
String |
getQueueUrl()
The URL of the Amazon SQS queue to take action on.
|
Integer |
getVisibilityTimeout()
The duration (in seconds) that the received messages are hidden from
subsequent retrieve requests after being retrieved by a
ReceiveMessage request. |
Integer |
getWaitTimeSeconds()
The duration (in seconds) for which the call will wait for a message
to arrive in the queue before returning.
|
int |
hashCode() |
void |
setAttributeNames(Collection<String> attributeNames)
A list of attributes that need to be returned along with each message.
|
void |
setMaxNumberOfMessages(Integer maxNumberOfMessages)
The maximum number of messages to return.
|
void |
setMessageAttributeNames(Collection<String> messageAttributeNames)
The name of the message attribute, where N is the index.
|
void |
setQueueUrl(String queueUrl)
The URL of the Amazon SQS queue to take action on.
|
void |
setVisibilityTimeout(Integer visibilityTimeout)
The duration (in seconds) that the received messages are hidden from
subsequent retrieve requests after being retrieved by a
ReceiveMessage request. |
void |
setWaitTimeSeconds(Integer waitTimeSeconds)
The duration (in seconds) for which the call will wait for a message
to arrive in the queue before returning.
|
String |
toString()
Returns a string representation of this object; useful for testing and
debugging.
|
ReceiveMessageRequest |
withAttributeNames(Collection<String> attributeNames)
A list of attributes that need to be returned along with each message.
|
ReceiveMessageRequest |
withAttributeNames(QueueAttributeName... attributeNames)
A list of attributes that need to be returned along with each message.
|
ReceiveMessageRequest |
withAttributeNames(String... attributeNames)
A list of attributes that need to be returned along with each message.
|
ReceiveMessageRequest |
withMaxNumberOfMessages(Integer maxNumberOfMessages)
The maximum number of messages to return.
|
ReceiveMessageRequest |
withMessageAttributeNames(Collection<String> messageAttributeNames)
The name of the message attribute, where N is the index.
|
ReceiveMessageRequest |
withMessageAttributeNames(String... messageAttributeNames)
The name of the message attribute, where N is the index.
|
ReceiveMessageRequest |
withQueueUrl(String queueUrl)
The URL of the Amazon SQS queue to take action on.
|
ReceiveMessageRequest |
withVisibilityTimeout(Integer visibilityTimeout)
The duration (in seconds) that the received messages are hidden from
subsequent retrieve requests after being retrieved by a
ReceiveMessage request. |
ReceiveMessageRequest |
withWaitTimeSeconds(Integer waitTimeSeconds)
The duration (in seconds) for which the call will wait for a message
to arrive in the queue before returning.
|
copyBaseTo, getCustomRequestHeaders, getGeneralProgressListener, getReadLimit, getRequestClientOptions, getRequestCredentials, getRequestMetricCollector, putCustomRequestHeader, setGeneralProgressListener, setRequestCredentials, setRequestMetricCollector, withGeneralProgressListener, withRequestMetricCollector
public ReceiveMessageRequest()
public ReceiveMessageRequest(String queueUrl)
queueUrl
- The URL of the Amazon SQS queue to take action on.public String getQueueUrl()
public void setQueueUrl(String queueUrl)
queueUrl
- The URL of the Amazon SQS queue to take action on.public ReceiveMessageRequest withQueueUrl(String queueUrl)
Returns a reference to this object so that method calls can be chained together.
queueUrl
- The URL of the Amazon SQS queue to take action on.public List<String> getAttributeNames()
The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).public void setAttributeNames(Collection<String> attributeNames)
The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).attributeNames
- A list of attributes that need to be returned along with each message.
The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).public ReceiveMessageRequest withAttributeNames(String... attributeNames)
The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).
NOTE: This method appends the values to the existing list (if
any). Use setAttributeNames(java.util.Collection)
or withAttributeNames(java.util.Collection)
if you want to override the
existing values.
Returns a reference to this object so that method calls can be chained together.
attributeNames
- A list of attributes that need to be returned along with each message.
The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).public ReceiveMessageRequest withAttributeNames(Collection<String> attributeNames)
The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).Returns a reference to this object so that method calls can be chained together.
attributeNames
- A list of attributes that need to be returned along with each message.
The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).public ReceiveMessageRequest withAttributeNames(QueueAttributeName... attributeNames)
The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).Returns a reference to this object so that method calls can be chained together.
attributeNames
- A list of attributes that need to be returned along with each message.
The following lists the names and descriptions of the attributes that can be returned:
All
- returns all
values.ApproximateFirstReceiveTimestamp
-
returns the time when the message was first received from the queue
(epoch time in milliseconds).ApproximateReceiveCount
- returns the number of times
a message has been received from the queue but not deleted.SenderId
- returns the AWS account number (or the IP
address, if anonymous access is allowed) of the sender.SentTimestamp
- returns the time when the message was
sent to the queue (epoch time in milliseconds).public List<String> getMessageAttributeNames()
When using ReceiveMessage
, you can send a
list of attribute names to receive, or you can return all of the
attributes by specifying "All" or ".*" in your request. You can also
use "foo.*" to return all message attributes starting with the "foo"
prefix.
When using ReceiveMessage
, you can send a
list of attribute names to receive, or you can return all of the
attributes by specifying "All" or ".*" in your request. You can also
use "foo.*" to return all message attributes starting with the "foo"
prefix.
public void setMessageAttributeNames(Collection<String> messageAttributeNames)
When using ReceiveMessage
, you can send a
list of attribute names to receive, or you can return all of the
attributes by specifying "All" or ".*" in your request. You can also
use "foo.*" to return all message attributes starting with the "foo"
prefix.
messageAttributeNames
- The name of the message attribute, where N is the index. The
message attribute name can contain the following characters: A-Z, a-z,
0-9, underscore (_), hyphen (-), and period (.). The name must not
start or end with a period, and it should not have successive periods.
The name is case sensitive and must be unique among all attribute
names for the message. The name can be up to 256 characters long. The
name cannot start with "AWS." or "Amazon." (or any variations in
casing), because these prefixes are reserved for use by Amazon Web
Services. When using ReceiveMessage
, you can send a
list of attribute names to receive, or you can return all of the
attributes by specifying "All" or ".*" in your request. You can also
use "foo.*" to return all message attributes starting with the "foo"
prefix.
public ReceiveMessageRequest withMessageAttributeNames(String... messageAttributeNames)
When using ReceiveMessage
, you can send a
list of attribute names to receive, or you can return all of the
attributes by specifying "All" or ".*" in your request. You can also
use "foo.*" to return all message attributes starting with the "foo"
prefix.
NOTE: This method appends the values to the existing list (if
any). Use setMessageAttributeNames(java.util.Collection)
or
withMessageAttributeNames(java.util.Collection)
if you want
to override the existing values.
Returns a reference to this object so that method calls can be chained together.
messageAttributeNames
- The name of the message attribute, where N is the index. The
message attribute name can contain the following characters: A-Z, a-z,
0-9, underscore (_), hyphen (-), and period (.). The name must not
start or end with a period, and it should not have successive periods.
The name is case sensitive and must be unique among all attribute
names for the message. The name can be up to 256 characters long. The
name cannot start with "AWS." or "Amazon." (or any variations in
casing), because these prefixes are reserved for use by Amazon Web
Services. When using ReceiveMessage
, you can send a
list of attribute names to receive, or you can return all of the
attributes by specifying "All" or ".*" in your request. You can also
use "foo.*" to return all message attributes starting with the "foo"
prefix.
public ReceiveMessageRequest withMessageAttributeNames(Collection<String> messageAttributeNames)
When using ReceiveMessage
, you can send a
list of attribute names to receive, or you can return all of the
attributes by specifying "All" or ".*" in your request. You can also
use "foo.*" to return all message attributes starting with the "foo"
prefix.
Returns a reference to this object so that method calls can be chained together.
messageAttributeNames
- The name of the message attribute, where N is the index. The
message attribute name can contain the following characters: A-Z, a-z,
0-9, underscore (_), hyphen (-), and period (.). The name must not
start or end with a period, and it should not have successive periods.
The name is case sensitive and must be unique among all attribute
names for the message. The name can be up to 256 characters long. The
name cannot start with "AWS." or "Amazon." (or any variations in
casing), because these prefixes are reserved for use by Amazon Web
Services. When using ReceiveMessage
, you can send a
list of attribute names to receive, or you can return all of the
attributes by specifying "All" or ".*" in your request. You can also
use "foo.*" to return all message attributes starting with the "foo"
prefix.
public Integer getMaxNumberOfMessages()
All of the messages are not necessarily returned.
All of the messages are not necessarily returned.
public void setMaxNumberOfMessages(Integer maxNumberOfMessages)
All of the messages are not necessarily returned.
maxNumberOfMessages
- The maximum number of messages to return. Amazon SQS never returns
more messages than this value but may return fewer. Values can be from
1 to 10. Default is 1. All of the messages are not necessarily returned.
public ReceiveMessageRequest withMaxNumberOfMessages(Integer maxNumberOfMessages)
All of the messages are not necessarily returned.
Returns a reference to this object so that method calls can be chained together.
maxNumberOfMessages
- The maximum number of messages to return. Amazon SQS never returns
more messages than this value but may return fewer. Values can be from
1 to 10. Default is 1. All of the messages are not necessarily returned.
public Integer getVisibilityTimeout()
ReceiveMessage
request.ReceiveMessage
request.public void setVisibilityTimeout(Integer visibilityTimeout)
ReceiveMessage
request.visibilityTimeout
- The duration (in seconds) that the received messages are hidden from
subsequent retrieve requests after being retrieved by a
ReceiveMessage
request.public ReceiveMessageRequest withVisibilityTimeout(Integer visibilityTimeout)
ReceiveMessage
request.
Returns a reference to this object so that method calls can be chained together.
visibilityTimeout
- The duration (in seconds) that the received messages are hidden from
subsequent retrieve requests after being retrieved by a
ReceiveMessage
request.public Integer getWaitTimeSeconds()
public void setWaitTimeSeconds(Integer waitTimeSeconds)
waitTimeSeconds
- The duration (in seconds) for which the call will wait for a message
to arrive in the queue before returning. If a message is available,
the call will return sooner than WaitTimeSeconds.public ReceiveMessageRequest withWaitTimeSeconds(Integer waitTimeSeconds)
Returns a reference to this object so that method calls can be chained together.
waitTimeSeconds
- The duration (in seconds) for which the call will wait for a message
to arrive in the queue before returning. If a message is available,
the call will return sooner than WaitTimeSeconds.public String toString()
toString
in class Object
Object.toString()
public ReceiveMessageRequest clone()
clone
in class AmazonWebServiceRequest
Copyright © 2015. All rights reserved.