AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Gives a detailed description of the result of an action on each entry in the request.
Namespace: Amazon.SQS.Model
Assembly: AWSSDK.SQS.dll
Version: 3.x.y.z
public class BatchResultErrorEntry
The BatchResultErrorEntry type exposes the following members
Name | Description | |
---|---|---|
BatchResultErrorEntry() |
Name | Type | Description | |
---|---|---|---|
Code | System.String |
Gets and sets the property Code. An error code representing why the action failed on this entry. |
|
Id | System.String |
Gets and sets the property Id.
The |
|
Message | System.String |
Gets and sets the property Message. A message explaining why the action failed on this entry. |
|
SenderFault | System.Boolean |
Gets and sets the property SenderFault. Specifies whether the error happened due to the caller of the batch API action. |
This example shows how to delete messages in batch.
var client = new AmazonSQSClient(); var request = new ReceiveMessageRequest { AttributeNames = new List<string>() { "All" }, MaxNumberOfMessages = 5, QueueUrl = "https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyTestQueue", VisibilityTimeout = (int)TimeSpan.FromMinutes(10).TotalSeconds, WaitTimeSeconds = (int)TimeSpan.FromSeconds(5).TotalSeconds }; var response = client.ReceiveMessage(request); var batchEntries = new List<DeleteMessageBatchRequestEntry>(); if (response.Messages.Count > 0) { foreach (var message in response.Messages) { var batchEntry = new DeleteMessageBatchRequestEntry { Id = message.MessageId, ReceiptHandle = message.ReceiptHandle }; batchEntries.Add(batchEntry); } var delRequest = new DeleteMessageBatchRequest { Entries = batchEntries, QueueUrl = "https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyTestQueue" }; var delResponse = client.DeleteMessageBatch(delRequest); if (delResponse.Failed.Count > 0) { Console.WriteLine("Failed deletions:"); foreach (var failure in delResponse.Failed) { Console.WriteLine(" For ID '" + failure.Id + "': "); Console.WriteLine(" Code = " + failure.Code); Console.WriteLine(" Message = " + failure.Message); Console.WriteLine(" Sender's fault? = " + failure.SenderFault); } } if (delResponse.Successful.Count > 0) { Console.WriteLine("Successful deletions:"); foreach (var success in delResponse.Successful) { Console.WriteLine(" ID '" + success.Id + "'"); } } } else { Console.WriteLine("No messages to delete."); }
This example shows how to send messages in batch.
var client = new AmazonSQSClient(); var entry1 = new SendMessageBatchRequestEntry { DelaySeconds = 0, Id = "Entry1", MessageAttributes = new Dictionary<string, MessageAttributeValue> { { "MyNameAttribute", new MessageAttributeValue { DataType = "String", StringValue = "John Doe" } }, { "MyAddressAttribute", new MessageAttributeValue { DataType = "String", StringValue = "123 Main St." } }, { "MyRegionAttribute", new MessageAttributeValue { DataType = "String", StringValue = "Any Town, United States" } } }, MessageBody = "John Doe customer information." }; var entry2 = new SendMessageBatchRequestEntry { DelaySeconds = 0, Id = "Entry2", MessageAttributes = new Dictionary<string, MessageAttributeValue> { { "MyNameAttribute", new MessageAttributeValue { DataType = "String", StringValue = "Jane Doe" } }, { "MyAddressAttribute", new MessageAttributeValue { DataType = "String", StringValue = "456 Center Road" } }, { "MyRegionAttribute", new MessageAttributeValue { DataType = "String", StringValue = "Any City, United States" } } }, MessageBody = "Jane Doe customer information." }; var entry3 = new SendMessageBatchRequestEntry { DelaySeconds = 0, Id = "Entry3", MessageAttributes = new Dictionary<string, MessageAttributeValue> { { "MyNameAttribute", new MessageAttributeValue { DataType = "String", StringValue = "Richard Doe" } }, { "MyAddressAttribute", new MessageAttributeValue { DataType = "String", StringValue = "789 East Blvd." } }, { "MyRegionAttribute", new MessageAttributeValue { DataType = "String", StringValue = "Anywhere, United States" } } }, MessageBody = "Richard Doe customer information." }; var request = new SendMessageBatchRequest { Entries = new List<SendMessageBatchRequestEntry>() { entry1, entry2, entry3 }, QueueUrl = "https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyTestQueue" }; var response = client.SendMessageBatch(request); if (response.Successful.Count > 0) { Console.WriteLine("Successfully sent:"); foreach (var success in response.Successful) { Console.WriteLine(" For ID: '" + success.Id + "':"); Console.WriteLine(" Message ID = " + success.MessageId); Console.WriteLine(" MD5 of message attributes = " + success.MD5OfMessageAttributes); Console.WriteLine(" MD5 of message body = " + success.MD5OfMessageBody); } } if (response.Failed.Count > 0) { Console.WriteLine("Failed to be sent:"); foreach (var fail in response.Failed) { Console.WriteLine(" For ID '" + fail.Id + "':"); Console.WriteLine(" Code = " + fail.Code); Console.WriteLine(" Message = " + fail.Message); Console.WriteLine(" Sender's fault? = " + fail.SenderFault); } }
.NET:
Supported in: 8.0 and newer, Core 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.5 and newer, 3.5