Amazon.SQS.AmazonSQSClient.DeleteMessageBatch C# (CSharp) Метод

DeleteMessageBatch() публичный Метод

Deletes up to ten messages from the specified queue. This is a batch version of DeleteMessage . The result of the action on each message is reported individually in the response.

Because the batch request can result in a combination of successful and unsuccessful actions, you should check for batch errors even when the call returns an HTTP status code of 200.

Some actions take lists of parameters. These lists are specified using the param.n notation. Values of n are integers starting from 1. For example, a parameter list with two elements looks like this:

&Attribute.1=this

&Attribute.2=that

/// Two or more batch entries in the request have the same Id. /// /// The batch request doesn't contain any entries. /// /// The Id of a batch entry in a batch request doesn't abide by the specification. /// /// The batch request contains more entries than permissible. ///
public DeleteMessageBatch ( DeleteMessageBatchRequest request ) : DeleteMessageBatchResponse
request Amazon.SQS.Model.DeleteMessageBatchRequest Container for the necessary parameters to execute the DeleteMessageBatch service method.
Результат Amazon.SQS.Model.DeleteMessageBatchResponse
        public DeleteMessageBatchResponse DeleteMessageBatch(DeleteMessageBatchRequest request)
        {
            var marshaller = new DeleteMessageBatchRequestMarshaller();
            var unmarshaller = DeleteMessageBatchResponseUnmarshaller.Instance;

            return Invoke<DeleteMessageBatchRequest,DeleteMessageBatchResponse>(request, marshaller, unmarshaller);
        }

Same methods

AmazonSQSClient::DeleteMessageBatch ( string queueUrl, List entries ) : DeleteMessageBatchResponse

Usage Example

Пример #1
0
        /// <summary>
        /// Deletes all messages from the input queue
        /// </summary>
        public void Purge()
        {
            if (_inputQueueAddress == null) return;

            using (var client = new AmazonSQSClient(_accessKeyId, _secretAccessKey, RegionEndpoint.EUCentral1))
            {
                try
                {
                    var response = client.ReceiveMessage(new ReceiveMessageRequest(_queueUrl)
                                          {
                                              MaxNumberOfMessages = 10
                                          });

                    while (response.Messages.Any())
                    {
                        var deleteResponse = client.DeleteMessageBatch(_queueUrl, response.Messages
                        .Select(m => new DeleteMessageBatchRequestEntry(m.MessageId, m.ReceiptHandle))
                        .ToList());

                        if (!deleteResponse.Failed.Any())
                        {
                            response = client.ReceiveMessage(new ReceiveMessageRequest(_queueUrl)
                                                             {
                                                                 MaxNumberOfMessages = 10
                                                             });
                        }
                        else
                        {
                            throw new Exception(deleteResponse.HttpStatusCode.ToString());
                        }
                    }


                }
                catch (Exception ex)
                {

                    Console.WriteLine("error in purge: " + ex.Message);
                }

            }





        }
All Usage Examples Of Amazon.SQS.AmazonSQSClient::DeleteMessageBatch
AmazonSQSClient