com.amazonaws.services.sqs.model.DeleteMessageResult Java Examples

The following examples show how to use com.amazonaws.services.sqs.model.DeleteMessageResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmazonSQSIdleQueueDeletingClient.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 6 votes vote down vote up
@Override
public DeleteMessageResult deleteMessage(DeleteMessageRequest request) {
    String queueUrl = request.getQueueUrl();
    try {
        heartbeatToQueueIfNecessary(queueUrl);
        return super.deleteMessage(request);
    } catch (QueueDoesNotExistException|ReceiptHandleIsInvalidException e) {
        try {
            return super.deleteMessage(
                    request.clone().withQueueUrl(alternateQueueName(request.getQueueUrl())));
        } catch (QueueDoesNotExistException e2) {
            // Silently fail - the message is definitely deleted after all!
            return new DeleteMessageResult();
        }
    }
}
 
Example #2
Source File: SqsClient.java    From kafka-connect-sqs with Apache License 2.0 5 votes vote down vote up
/**
 * Delete a message from the SQS queue.
 *
 * @param url           SQS queue url.
 * @param receiptHandle Message receipt handle of message to delete.
 */
public void delete(final String url, final String receiptHandle) {
  Guard.verifyValidUrl(url);
  Guard.verifyNotNullOrEmpty(receiptHandle, "receiptHandle");

  final DeleteMessageRequest request = new DeleteMessageRequest(url, receiptHandle);
  final DeleteMessageResult result = client.deleteMessage(request);

  log.debug(".delete:receipt-handle={}, rc={}", receiptHandle, result.getSdkHttpMetadata().getHttpStatusCode());
}
 
Example #3
Source File: AmazonSQSVirtualQueuesClient.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 5 votes vote down vote up
public DeleteMessageResult deleteMessage(DeleteMessageRequest request) {
    heartbeat();
    DeleteMessageRequest virtualQueueResult = new DeleteMessageRequest()
            .withQueueUrl(id.getHostQueueUrl())
            .withReceiptHandle(request.getReceiptHandle());
    return amazonSqsToBeExtended.deleteMessage(virtualQueueResult);
}
 
Example #4
Source File: MockSQSQueue.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 5 votes vote down vote up
public DeleteMessageResult deleteMessage(DeleteMessageRequest request) {
    String receiptHandle = request.getReceiptHandle();
    if (inflight.remove(receiptHandle) == null) {
        // TODO-RS: Error? Or at least a hook so tests can
        // assert it actually succeeded?
    }
    return new DeleteMessageResult();
}
 
Example #5
Source File: AmazonSQSVirtualQueuesClient.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteMessageResult deleteMessage(DeleteMessageRequest request) {
    return getVirtualQueue(request.getQueueUrl())
            .map(virtualQueue -> virtualQueue.deleteMessage(request))
            .orElseGet(() -> amazonSqsToBeExtended.deleteMessage(request));
}
 
Example #6
Source File: AbstractAmazonSQSClientWrapper.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteMessageResult deleteMessage(DeleteMessageRequest request) {
    request.getRequestClientOptions().appendUserAgent(userAgent);
    return amazonSqsToBeExtended.deleteMessage(request);
}
 
Example #7
Source File: MockSQS.java    From amazon-sqs-java-temporary-queues-client with Apache License 2.0 4 votes vote down vote up
@Override
public DeleteMessageResult deleteMessage(DeleteMessageRequest request) {
    return getQueue(request.getQueueUrl()).deleteMessage(request);
}
 
Example #8
Source File: AmazonSQSExtendedClient.java    From amazon-sqs-java-extended-client-lib with Apache License 2.0 4 votes vote down vote up
/**
 * <p>
 * Deletes the specified message from the specified queue and deletes the
 * message payload from Amazon S3 when necessary. You specify the message by
 * using the message's <code>receipt handle</code> and not the
 * <code>message ID</code> you received when you sent the message. Even if
 * the message is locked by another reader due to the visibility timeout
 * setting, it is still deleted from the queue. If you leave a message in
 * the queue for longer than the queue's configured retention period, Amazon
 * SQS automatically deletes it.
 * </p>
 * <p>
 * <b>NOTE:</b> The receipt handle is associated with a specific instance of
 * receiving the message. If you receive a message more than once, the
 * receipt handle you get each time you receive the message is different.
 * When you request DeleteMessage, if you don't provide the most recently
 * received receipt handle for the message, the request will still succeed,
 * but the message might not be deleted.
 * </p>
 * <p>
 * <b>IMPORTANT:</b> It is possible you will receive a message even after
 * you have deleted it. This might happen on rare occasions if one of the
 * servers storing a copy of the message is unavailable when you request to
 * delete the message. The copy remains on the server and might be returned
 * to you again on a subsequent receive request. You should create your
 * system to be idempotent so that receiving a particular message more than
 * once is not a problem.
 * </p>
 *
 * @param deleteMessageRequest
 *            Container for the necessary parameters to execute the
 *            DeleteMessage service method on AmazonSQS.
 *
 * @return The response from the DeleteMessage service method, as returned
 *         by AmazonSQS.
 *
 * @throws ReceiptHandleIsInvalidException
 * @throws InvalidIdFormatException
 *
 * @throws AmazonClientException
 *             If any internal errors are encountered inside the client
 *             while attempting to make the request or handle the response.
 *             For example if a network connection is not available.
 * @throws AmazonServiceException
 *             If an error response is returned by AmazonSQS indicating
 *             either a problem with the data in the request, or a server
 *             side issue.
 */
public DeleteMessageResult deleteMessage(DeleteMessageRequest deleteMessageRequest) {

	if (deleteMessageRequest == null) {
		String errorMessage = "deleteMessageRequest cannot be null.";
		LOG.error(errorMessage);
		throw new AmazonClientException(errorMessage);
	}

	deleteMessageRequest.getRequestClientOptions().appendUserAgent(SQSExtendedClientConstants.USER_AGENT_HEADER);

	if (!clientConfiguration.isLargePayloadSupportEnabled()) {
		return super.deleteMessage(deleteMessageRequest);
	}

	String receiptHandle = deleteMessageRequest.getReceiptHandle();
	String origReceiptHandle = receiptHandle;
	if (isS3ReceiptHandle(receiptHandle)) {
		deleteMessagePayloadFromS3(receiptHandle);
		origReceiptHandle = getOrigReceiptHandle(receiptHandle);
	}
	deleteMessageRequest.setReceiptHandle(origReceiptHandle);
	return super.deleteMessage(deleteMessageRequest);
}
 
Example #9
Source File: DeleteMessageHandler.java    From spring-cloud-aws with Apache License 2.0 4 votes vote down vote up
@Override
public void onSuccess(DeleteMessageRequest request,
		DeleteMessageResult deleteMessageResult) {
	logger.trace("'{}' receiptHandle is deleted successfully",
			request.getReceiptHandle());
}
 
Example #10
Source File: AmazonSQSExtendedClientBase.java    From amazon-sqs-java-extended-client-lib with Apache License 2.0 2 votes vote down vote up
/**
    * <p>
    * Deletes the specified message from the specified queue. You specify
    * the message by using the message's <code>receipt handle</code> and not
    * the <code>message ID</code> you received when you sent the message.
    * Even if the message is locked by another reader due to the visibility
    * timeout setting, it is still deleted from the queue. If you leave a
    * message in the queue for longer than the queue's configured retention
    * period, Amazon SQS automatically deletes it.
    * </p>
    * <p>
    * <b>NOTE:</b> The receipt handle is associated with a specific
    * instance of receiving the message. If you receive a message more than
    * once, the receipt handle you get each time you receive the message is
    * different. When you request DeleteMessage, if you don't provide the
    * most recently received receipt handle for the message, the request
    * will still succeed, but the message might not be deleted.
    * </p>
    * <p>
    * <b>IMPORTANT:</b> It is possible you will receive a message even
    * after you have deleted it. This might happen on rare occasions if one
    * of the servers storing a copy of the message is unavailable when you
    * request to delete the message. The copy remains on the server and
    * might be returned to you again on a subsequent receive request. You
    * should create your system to be idempotent so that receiving a
    * particular message more than once is not a problem.
    * </p>
    *
    * @param deleteMessageRequest Container for the necessary parameters to
    *           execute the DeleteMessage service method on AmazonSQS.
    *
    * @return The response from the DeleteMessage service method, as returned
    *         by AmazonSQS.
    * 
    * @throws ReceiptHandleIsInvalidException
    * @throws InvalidIdFormatException
    *
    * @throws AmazonClientException
    *             If any internal errors are encountered inside the client while
    *             attempting to make the request or handle the response.  For example
    *             if a network connection is not available.
    * @throws AmazonServiceException
    *             If an error response is returned by AmazonSQS indicating
    *             either a problem with the data in the request, or a server side issue.
    */
public DeleteMessageResult deleteMessage(DeleteMessageRequest deleteMessageRequest) {
	return amazonSqsToBeExtended.deleteMessage(deleteMessageRequest);
}
 
Example #11
Source File: AmazonSQSExtendedClientBase.java    From amazon-sqs-java-extended-client-lib with Apache License 2.0 2 votes vote down vote up
/**
 * <p>
 * Deletes the specified message from the specified queue. You specify the
 * message by using the message's <code>receipt handle</code> and not the
 * <code>message ID</code> you received when you sent the message. Even if
 * the message is locked by another reader due to the visibility timeout
 * setting, it is still deleted from the queue. If you leave a message in
 * the queue for longer than the queue's configured retention period, Amazon
 * SQS automatically deletes it.
 * </p>
 * <p>
 * <b>NOTE:</b> The receipt handle is associated with a specific instance of
 * receiving the message. If you receive a message more than once, the
 * receipt handle you get each time you receive the message is different.
 * When you request DeleteMessage, if you don't provide the most recently
 * received receipt handle for the message, the request will still succeed,
 * but the message might not be deleted.
 * </p>
 * <p>
 * <b>IMPORTANT:</b> It is possible you will receive a message even after
 * you have deleted it. This might happen on rare occasions if one of the
 * servers storing a copy of the message is unavailable when you request to
 * delete the message. The copy remains on the server and might be returned
 * to you again on a subsequent receive request. You should create your
 * system to be idempotent so that receiving a particular message more than
 * once is not a problem.
 * </p>
 * 
 * @param queueUrl
 *            The URL of the Amazon SQS queue to take action on.
 * @param receiptHandle
 *            The receipt handle associated with the message to delete.
 *
 * @return The response from the DeleteMessage service method, as returned
 *         by AmazonSQS.
 * 
 * @throws ReceiptHandleIsInvalidException
 * @throws InvalidIdFormatException
 *
 * @throws AmazonClientException
 *             If any internal errors are encountered inside the client
 *             while attempting to make the request or handle the response.
 *             For example if a network connection is not available.
 * @throws AmazonServiceException
 *             If an error response is returned by AmazonSQS indicating
 *             either a problem with the data in the request, or a server
 *             side issue.
 */
public DeleteMessageResult deleteMessage(String queueUrl, String receiptHandle)
		throws AmazonServiceException, AmazonClientException {

	return amazonSqsToBeExtended.deleteMessage(queueUrl, receiptHandle);
}
 
Example #12
Source File: AmazonSQSExtendedClient.java    From amazon-sqs-java-extended-client-lib with Apache License 2.0 2 votes vote down vote up
/**
 * <p>
 * Deletes the specified message from the specified queue and deletes the
 * message payload from Amazon S3 when necessary. You specify the message by
 * using the message's <code>receipt handle</code> and not the
 * <code>message ID</code> you received when you sent the message. Even if
 * the message is locked by another reader due to the visibility timeout
 * setting, it is still deleted from the queue. If you leave a message in
 * the queue for longer than the queue's configured retention period, Amazon
 * SQS automatically deletes it.
 * </p>
 * <p>
 * <b>NOTE:</b> The receipt handle is associated with a specific instance of
 * receiving the message. If you receive a message more than once, the
 * receipt handle you get each time you receive the message is different.
 * When you request DeleteMessage, if you don't provide the most recently
 * received receipt handle for the message, the request will still succeed,
 * but the message might not be deleted.
 * </p>
 * <p>
 * <b>IMPORTANT:</b> It is possible you will receive a message even after
 * you have deleted it. This might happen on rare occasions if one of the
 * servers storing a copy of the message is unavailable when you request to
 * delete the message. The copy remains on the server and might be returned
 * to you again on a subsequent receive request. You should create your
 * system to be idempotent so that receiving a particular message more than
 * once is not a problem.
 * </p>
 *
 * @param queueUrl
 *            The URL of the Amazon SQS queue to take action on.
 * @param receiptHandle
 *            The receipt handle associated with the message to delete.
 *
 * @return The response from the DeleteMessage service method, as returned
 *         by AmazonSQS.
 *
 * @throws ReceiptHandleIsInvalidException
 * @throws InvalidIdFormatException
 *
 * @throws AmazonClientException
 *             If any internal errors are encountered inside the client
 *             while attempting to make the request or handle the response.
 *             For example if a network connection is not available.
 * @throws AmazonServiceException
 *             If an error response is returned by AmazonSQS indicating
 *             either a problem with the data in the request, or a server
 *             side issue.
 */
public DeleteMessageResult deleteMessage(String queueUrl, String receiptHandle) {
	DeleteMessageRequest deleteMessageRequest = new DeleteMessageRequest(queueUrl, receiptHandle);
	return deleteMessage(deleteMessageRequest);
}