Purpose of Amazon SQS message's body as against message's attributes

Message attributes are supposed to be used as message metadata (like timestamp or possibly some category) and not the message itself.

Ideally, message payload should be given in the message body

So, for example if you are supporting JSON and XML payloads then possibly you can put payload type as message attribute and then when you fetch the message, based on this payload type attribute you decide between the JSON message processor or XML message processor. This is just a superficial example to explain the usage of attributes and body

Following is the extract from AWS Doc

Amazon SQS provides support for message attributes. Message attributes allow you to provide structured metadata items (such as timestamps, geospatial data, signatures, and identifiers) about the message. Message attributes are optional and separate from, but sent along with, the message body. This information can be used by the receiver of the message to help decide how to handle the message without having to first process the message body. Each message can have up to 10 attributes. To specify message attributes, you can use the AWS Management Console, AWS software development kits (SDKs), or query API.


To map with the traditional queue provider such as rabbitMQ or Kafka world.

We can understand as below:

message_body=message_payload
message_attributes=message_headers ( can be used to apply different routing and filtering message using their headers information)

In fact, I prefer the term payload and headers more than what terms used in aws sqs, its abit confusing.

Message attributes sound more like the attributes of message payload