Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.sqs.model;
 
 
Container for the parameters to the ChangeMessageVisibility operation.

Changes the visibility timeout of a specified message in a queue to a new value. The maximum allowed timeout value you can set the value to is 12 hours. This means you can't extend the timeout of a message in an existing queue to more than a total visibility timeout of 12 hours. (For more information visibility timeout, see Visibility Timeout in the Amazon SQS Developer Guide .)

For example, let's say you have a message and its default message visibility timeout is 30 minutes. You could call ChangeMessageVisiblity with a value of two hours and the effective timeout would be two hours and 30 minutes. When that time comes near you could again extend the time out by calling ChangeMessageVisiblity, but this time the maximum allowed timeout would be 9 hours and 30 minutes.

NOTE: There is a 120,000 limit for the number of inflight messages per queue. Messages are inflight after they have been received from the queue by a consuming component, but have not yet been deleted from the queue. If you reach the 120,000 limit, you will receive an OverLimit error message from Amazon SQS. To help avoid reaching the limit, you should delete the messages from the queue after they have been processed. You can also increase the number of queues you use to process the messages.

IMPORTANT:If you attempt to set the VisibilityTimeout to an amount more than the maximum time left, Amazon SQS returns an error. It will not automatically recalculate and increase the timeout to the maximum time remaining.

IMPORTANT:Unlike with a queue, when you change the visibility timeout for a specific message, that timeout value is applied immediately but is not saved in memory for that message. If you don't delete a message after it is received, the visibility timeout for the message the next time it is received reverts to the original timeout value, not the value you set with the ChangeMessageVisibility action.

 
 public class ChangeMessageVisibilityRequest extends AmazonWebServiceRequest implements SerializableCloneable {

    
The URL of the Amazon SQS queue to take action on.
 
     private String queueUrl;

    
The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action.
 
     private String receiptHandle;

    
The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout.
 
     private Integer visibilityTimeout;

    
Default constructor for a new ChangeMessageVisibilityRequest object. Callers should use the setter or fluent setter (with...) methods to initialize this object after creating it.
 
     public ChangeMessageVisibilityRequest() {}
    
    
Constructs a new ChangeMessageVisibilityRequest 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.
receiptHandle The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action.
visibilityTimeout The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout.
    public ChangeMessageVisibilityRequest(String queueUrlString receiptHandleInteger visibilityTimeout) {
        setQueueUrl(queueUrl);
        setReceiptHandle(receiptHandle);
        setVisibilityTimeout(visibilityTimeout);
    }

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

Returns:
The URL of the Amazon SQS queue to take action on.
    public String getQueueUrl() {
        return ;
    }
    
    
The URL of the Amazon SQS queue to take action on.

Parameters:
queueUrl The URL of the Amazon SQS queue to take action on.
    public void setQueueUrl(String queueUrl) {
        this. = 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.
        this. = queueUrl;
        return this;
    }

    
The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action.

Returns:
The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action.
    public String getReceiptHandle() {
        return ;
    }
    
    
The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action.

Parameters:
receiptHandle The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action.
    public void setReceiptHandle(String receiptHandle) {
        this. = receiptHandle;
    }
    
    
The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action.

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

Parameters:
receiptHandle The receipt handle associated with the message whose visibility timeout should be changed. This parameter is returned by the ReceiveMessage action.
Returns:
A reference to this updated object so that method calls can be chained together.
    public ChangeMessageVisibilityRequest withReceiptHandle(String receiptHandle) {
        this. = receiptHandle;
        return this;
    }

    
The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout.

Returns:
The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout.
    public Integer getVisibilityTimeout() {
        return ;
    }
    
    
The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout.

Parameters:
visibilityTimeout The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout.
    public void setVisibilityTimeout(Integer visibilityTimeout) {
        this. = visibilityTimeout;
    }
    
    
The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout.

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

Parameters:
visibilityTimeout The new value (in seconds - from 0 to 43200 - maximum 12 hours) for the message's visibility timeout.
Returns:
A reference to this updated object so that method calls can be chained together.
    public ChangeMessageVisibilityRequest withVisibilityTimeout(Integer visibilityTimeout) {
        this. = visibilityTimeout;
        return this;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getQueueUrl() != nullsb.append("QueueUrl: " + getQueueUrl() + ",");
        if (getReceiptHandle() != nullsb.append("ReceiptHandle: " + getReceiptHandle() + ",");
        if (getVisibilityTimeout() != nullsb.append("VisibilityTimeout: " + getVisibilityTimeout() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getQueueUrl() == null) ? 0 : getQueueUrl().hashCode()); 
        hashCode = prime * hashCode + ((getReceiptHandle() == null) ? 0 : getReceiptHandle().hashCode()); 
        hashCode = prime * hashCode + ((getVisibilityTimeout() == null) ? 0 : getVisibilityTimeout().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof ChangeMessageVisibilityRequest == falsereturn false;
        
        if (other.getQueueUrl() == null ^ this.getQueueUrl() == nullreturn false;
        if (other.getQueueUrl() != null && other.getQueueUrl().equals(this.getQueueUrl()) == falsereturn false
        if (other.getReceiptHandle() == null ^ this.getReceiptHandle() == nullreturn false;
        if (other.getReceiptHandle() != null && other.getReceiptHandle().equals(this.getReceiptHandle()) == falsereturn false
        if (other.getVisibilityTimeout() == null ^ this.getVisibilityTimeout() == nullreturn false;
        if (other.getVisibilityTimeout() != null && other.getVisibilityTimeout().equals(this.getVisibilityTimeout()) == falsereturn false
        return true;
    }
    
    @Override
        
            return (ChangeMessageVisibilityRequestsuper.clone();
    }
}
    
New to GrepCode? Check out our FAQ X