com.amazonaws.services.sqs.model
Class ReceiveMessageRequest

java.lang.Object
  extended by com.amazonaws.AmazonWebServiceRequest
      extended by com.amazonaws.services.sqs.model.ReceiveMessageRequest
All Implemented Interfaces:
java.io.Serializable

public class ReceiveMessageRequest
extends AmazonWebServiceRequest
implements java.io.Serializable

Container for the parameters to the 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:

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.

See Also:
AmazonSQS.receiveMessage(ReceiveMessageRequest), Serialized Form

Constructor Summary
ReceiveMessageRequest()
          Default constructor for a new ReceiveMessageRequest object.
ReceiveMessageRequest(java.lang.String queueUrl)
          Constructs a new ReceiveMessageRequest object.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.util.List<java.lang.String> getAttributeNames()
          A list of attributes that need to be returned along with each message.
 java.lang.Integer getMaxNumberOfMessages()
          The maximum number of messages to return.
 java.util.List<java.lang.String> getMessageAttributeNames()
          The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.).
 java.lang.String getQueueUrl()
          The URL of the Amazon SQS queue to take action on.
 java.lang.Integer getVisibilityTimeout()
          The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.
 java.lang.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(java.util.Collection<java.lang.String> attributeNames)
          A list of attributes that need to be returned along with each message.
 void setMaxNumberOfMessages(java.lang.Integer maxNumberOfMessages)
          The maximum number of messages to return.
 void setMessageAttributeNames(java.util.Collection<java.lang.String> messageAttributeNames)
          The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.).
 void setQueueUrl(java.lang.String queueUrl)
          The URL of the Amazon SQS queue to take action on.
 void setVisibilityTimeout(java.lang.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(java.lang.Integer waitTimeSeconds)
          The duration (in seconds) for which the call will wait for a message to arrive in the queue before returning.
 java.lang.String toString()
          Returns a string representation of this object; useful for testing and debugging.
 ReceiveMessageRequest withAttributeNames(java.util.Collection<java.lang.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(java.lang.String... attributeNames)
          A list of attributes that need to be returned along with each message.
 ReceiveMessageRequest withMaxNumberOfMessages(java.lang.Integer maxNumberOfMessages)
          The maximum number of messages to return.
 ReceiveMessageRequest withMessageAttributeNames(java.util.Collection<java.lang.String> messageAttributeNames)
          The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.).
 ReceiveMessageRequest withMessageAttributeNames(java.lang.String... messageAttributeNames)
          The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.).
 ReceiveMessageRequest withQueueUrl(java.lang.String queueUrl)
          The URL of the Amazon SQS queue to take action on.
 ReceiveMessageRequest withVisibilityTimeout(java.lang.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(java.lang.Integer waitTimeSeconds)
          The duration (in seconds) for which the call will wait for a message to arrive in the queue before returning.
 
Methods inherited from class com.amazonaws.AmazonWebServiceRequest
copyPrivateRequestParameters, getDelegationToken, getRequestClientOptions, getRequestCredentials, getRequestMetricCollector, setDelegationToken, setRequestCredentials, setRequestMetricCollector, withRequestMetricCollector
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReceiveMessageRequest

public ReceiveMessageRequest()
Default constructor for a new ReceiveMessageRequest object. Callers should use the setter or fluent setter (with...) methods to initialize this object after creating it.


ReceiveMessageRequest

public ReceiveMessageRequest(java.lang.String queueUrl)
Constructs a new ReceiveMessageRequest object. Callers should use the setter or fluent setter (with...) methods to initialize any additional object members.

Parameters:
queueUrl - The URL of the Amazon SQS queue to take action on.
Method Detail

getQueueUrl

public java.lang.String getQueueUrl()
The URL of the Amazon SQS queue to take action on.

Returns:
The URL of the Amazon SQS queue to take action on.

setQueueUrl

public void setQueueUrl(java.lang.String queueUrl)
The URL of the Amazon SQS queue to take action on.

Parameters:
queueUrl - The URL of the Amazon SQS queue to take action on.

withQueueUrl

public ReceiveMessageRequest withQueueUrl(java.lang.String queueUrl)
The URL of the Amazon SQS queue to take action on.

Returns a reference to this object so that method calls can be chained together.

Parameters:
queueUrl - The URL of the Amazon SQS queue to take action on.
Returns:
A reference to this updated object so that method calls can be chained together.

getAttributeNames

public java.util.List<java.lang.String> getAttributeNames()
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:

Returns:
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 (epoch time in milliseconds).
  • ApproximateReceiveCount - returns the number of times a message has been received 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 (epoch time in milliseconds).

setAttributeNames

public void setAttributeNames(java.util.Collection<java.lang.String> 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:

Parameters:
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 (epoch time in milliseconds).
  • ApproximateReceiveCount - returns the number of times a message has been received 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 (epoch time in milliseconds).

withAttributeNames

public ReceiveMessageRequest withAttributeNames(java.lang.String... 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:

Returns a reference to this object so that method calls can be chained together.

Parameters:
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 (epoch time in milliseconds).
  • ApproximateReceiveCount - returns the number of times a message has been received 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 (epoch time in milliseconds).
Returns:
A reference to this updated object so that method calls can be chained together.

withAttributeNames

public ReceiveMessageRequest withAttributeNames(java.util.Collection<java.lang.String> 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:

Returns a reference to this object so that method calls can be chained together.

Parameters:
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 (epoch time in milliseconds).
  • ApproximateReceiveCount - returns the number of times a message has been received 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 (epoch time in milliseconds).
Returns:
A reference to this updated object so that method calls can be chained together.

withAttributeNames

public ReceiveMessageRequest withAttributeNames(QueueAttributeName... 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:

Returns a reference to this object so that method calls can be chained together.

Parameters:
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 (epoch time in milliseconds).
  • ApproximateReceiveCount - returns the number of times a message has been received 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 (epoch time in milliseconds).
Returns:
A reference to this updated object so that method calls can be chained together.

getMessageAttributeNames

public java.util.List<java.lang.String> getMessageAttributeNames()
The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.). The message attribute name must not start or end with a period, and it should not have successive periods. The message attribute name is case sensitive and must be unique among all attribute names for the message. The message attribute name can be up to 256 characters long. Attribute names cannot start with "AWS." or "Amazon." because these prefixes are reserved for use by Amazon Web Services.

Returns:
The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.). The message attribute name must not start or end with a period, and it should not have successive periods. The message attribute name is case sensitive and must be unique among all attribute names for the message. The message attribute name can be up to 256 characters long. Attribute names cannot start with "AWS." or "Amazon." because these prefixes are reserved for use by Amazon Web Services.

setMessageAttributeNames

public void setMessageAttributeNames(java.util.Collection<java.lang.String> messageAttributeNames)
The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.). The message attribute name must not start or end with a period, and it should not have successive periods. The message attribute name is case sensitive and must be unique among all attribute names for the message. The message attribute name can be up to 256 characters long. Attribute names cannot start with "AWS." or "Amazon." because these prefixes are reserved for use by Amazon Web Services.

Parameters:
messageAttributeNames - The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.). The message attribute name must not start or end with a period, and it should not have successive periods. The message attribute name is case sensitive and must be unique among all attribute names for the message. The message attribute name can be up to 256 characters long. Attribute names cannot start with "AWS." or "Amazon." because these prefixes are reserved for use by Amazon Web Services.

withMessageAttributeNames

public ReceiveMessageRequest withMessageAttributeNames(java.lang.String... messageAttributeNames)
The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.). The message attribute name must not start or end with a period, and it should not have successive periods. The message attribute name is case sensitive and must be unique among all attribute names for the message. The message attribute name can be up to 256 characters long. Attribute names cannot start with "AWS." or "Amazon." because these prefixes are reserved for use by Amazon Web Services.

Returns a reference to this object so that method calls can be chained together.

Parameters:
messageAttributeNames - The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.). The message attribute name must not start or end with a period, and it should not have successive periods. The message attribute name is case sensitive and must be unique among all attribute names for the message. The message attribute name can be up to 256 characters long. Attribute names cannot start with "AWS." or "Amazon." because these prefixes are reserved for use by Amazon Web Services.
Returns:
A reference to this updated object so that method calls can be chained together.

withMessageAttributeNames

public ReceiveMessageRequest withMessageAttributeNames(java.util.Collection<java.lang.String> messageAttributeNames)
The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.). The message attribute name must not start or end with a period, and it should not have successive periods. The message attribute name is case sensitive and must be unique among all attribute names for the message. The message attribute name can be up to 256 characters long. Attribute names cannot start with "AWS." or "Amazon." because these prefixes are reserved for use by Amazon Web Services.

Returns a reference to this object so that method calls can be chained together.

Parameters:
messageAttributeNames - The message attribute Name can contain the following characters: A-Z, a-z, 0-9, underscore(_), hyphen(-), and period (.). The message attribute name must not start or end with a period, and it should not have successive periods. The message attribute name is case sensitive and must be unique among all attribute names for the message. The message attribute name can be up to 256 characters long. Attribute names cannot start with "AWS." or "Amazon." because these prefixes are reserved for use by Amazon Web Services.
Returns:
A reference to this updated object so that method calls can be chained together.

getMaxNumberOfMessages

public java.lang.Integer getMaxNumberOfMessages()
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.

Returns:
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.


setMaxNumberOfMessages

public void setMaxNumberOfMessages(java.lang.Integer 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.

Parameters:
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.


withMaxNumberOfMessages

public ReceiveMessageRequest withMaxNumberOfMessages(java.lang.Integer 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.

Returns a reference to this object so that method calls can be chained together.

Parameters:
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.

Returns:
A reference to this updated object so that method calls can be chained together.

getVisibilityTimeout

public java.lang.Integer getVisibilityTimeout()
The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

Returns:
The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

setVisibilityTimeout

public void setVisibilityTimeout(java.lang.Integer visibilityTimeout)
The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

Parameters:
visibilityTimeout - The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

withVisibilityTimeout

public ReceiveMessageRequest withVisibilityTimeout(java.lang.Integer visibilityTimeout)
The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

Returns a reference to this object so that method calls can be chained together.

Parameters:
visibilityTimeout - The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.
Returns:
A reference to this updated object so that method calls can be chained together.

getWaitTimeSeconds

public java.lang.Integer getWaitTimeSeconds()
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.

Returns:
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.

setWaitTimeSeconds

public void setWaitTimeSeconds(java.lang.Integer 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.

Parameters:
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.

withWaitTimeSeconds

public ReceiveMessageRequest withWaitTimeSeconds(java.lang.Integer 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.

Returns a reference to this object so that method calls can be chained together.

Parameters:
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.
Returns:
A reference to this updated object so that method calls can be chained together.

toString

public java.lang.String toString()
Returns a string representation of this object; useful for testing and debugging.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this object.
See Also:
Object.toString()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.