AWS SDK Version 3 for .NET
API Reference

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.

The user-specified message attribute value. For string data types, the Value attribute has the same restrictions on the content as the message body. For more information, see SendMessage.

Name, type, value and the message body must not be empty or null. All parts of the message attribute, including Name, Type, and Value, are part of the message size restriction (256 KiB or 262,144 bytes).

Inheritance Hierarchy

System.Object
  Amazon.SQS.Model.MessageAttributeValue

Namespace: Amazon.SQS.Model
Assembly: AWSSDK.SQS.dll
Version: 3.x.y.z

Syntax

C#
public class MessageAttributeValue

The MessageAttributeValue type exposes the following members

Constructors

NameDescription
Public Method MessageAttributeValue()

Properties

NameTypeDescription
Public Property BinaryListValues System.Collections.Generic.List<System.IO.MemoryStream>

Gets and sets the property BinaryListValues.

Not implemented. Reserved for future use.

Public Property BinaryValue System.IO.MemoryStream

Gets and sets the property BinaryValue.

Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

Public Property DataType System.String

Gets and sets the property DataType.

Amazon SQS supports the following logical data types: String, Number, and Binary. For the Number data type, you must use StringValue.

You can also append custom labels. For more information, see Amazon SQS Message Attributes in the Amazon SQS Developer Guide.

Public Property StringListValues System.Collections.Generic.List<System.String>

Gets and sets the property StringListValues.

Not implemented. Reserved for future use.

Public Property StringValue System.String

Gets and sets the property StringValue.

Strings are Unicode with UTF-8 binary encoding. For a list of code values, see ASCII Printable Characters.

Examples

This example shows how to send a message.

Send message example

var client = new AmazonSQSClient();

var request = new SendMessageRequest
{
  DelaySeconds = (int)TimeSpan.FromSeconds(5).TotalSeconds,
  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.",
  QueueUrl = "https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyTestQueue"
};

var response = client.SendMessage(request);

Console.WriteLine("For message ID '" + response.MessageId + "':");
Console.WriteLine("  MD5 of message attributes: " +
  response.MD5OfMessageAttributes);
Console.WriteLine("  MD5 of message body: " + response.MD5OfMessageBody);
      

Version Information

.NET Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.5, 4.0, 3.5