Systems in modern Cloud Architecture decouple applications into smaller, more independent building blocks, making them easier to develop, maintain, and deploy. Message queue provides coordination and communication between these distributed applications while improving the system’s Reliability, Performance, and Scalability. A message queue is an asynchronous service to service communication between Servers and Microservices Architecture. In a queue, messages are stored until they are processed and deleted, where every message is only processed once by a single customer.
Businesses can use message queues to smooth spiky workloads, decouple heavyweight processing, and buffer or batch work. Amazon Web Services (AWS) offer a message queue solution called Simple Queue Service (SQS).
Through scripts, you can automate the entire process of controlling and managing AWS services using the AWS Command Line Interface. Users can fully automate cloud infrastructure with the help of these scripts.
This blog extensively explains AWS CLI SQS and how messages are sent and received in SQS using CLI. In addition to that, it also explains some of the key benefits of using AWS SQS.
What is AWS SQS?
Amazon Simple Queue Service is a fully managed message queuing service for decoupling and scaling microservices, distributed systems, and serverless applications. SQS removes the complexity and overhead of managing and operating message-oriented middleware, allowing developers to concentrate on unique work. You can send, store, and receive messages between software components using SQS at any volume without losing messages or requiring the availability of other services. Using the AWS Management Console, your preferred Command Line Interface or SDK, and three simple commands, you can get started with SQS in minutes.
AWS SQS is a hosted queue that allows you to integrate and decouple distributed software systems and components while maintaining security, durability, and availability. Dead-letter queues and cost allocation tags are two common constructs offered by Amazon SQS. It provides a generic web services API that you can use with any AWS SDK-supported programming language.
There are two types of message queues available in SQS. Standard queues provide the highest throughput, best-effort ordering, and delivery at least once. SQS FIFO queues are designed to ensure that messages are processed exactly once, in the order in which they are received.
Amazon SQS is a messaging service that has been commoditized. IBM WebSphere MQ and Microsoft Message Queuing are two well-known examples of messaging service technologies. Users do not need to maintain their server, unlike with these technologies. Amazon handles it for them and charges a per-use fee for the SQS service.
Key Benefits of AWS SQS
- Eliminate Administrative Overhead: AWS is responsible for all ongoing operations and infrastructure required to provide a highly available and scalable message queuing service. There is no upfront cost with SQS, no need to purchase, install, or configure messaging software, and no time-consuming infrastructure build-out and maintenance. SQS queues are created dynamically and scale automatically, allowing you to quickly and efficiently build and grow applications.
- Reliably Deliver Messages: Amazon SQS allows you to send any amount of data at any speed, without losing messages or requiring the use of other services. SQS allows you to decouple application components so that they can run and fail independently, boosting the system’s overall fault tolerance. Every message is duplicated and stored in multiple Availability Zones to ensure that it is available whenever it is needed.
- Keep Sensitive Data Secure: Using Server-Side Encryption (SSE) to encrypt each message body, Amazon SQS can be used to exchange sensitive data between applications. The integration of Amazon SQS SSE with AWS Key Management Service (KMS) allows you to manage the keys that protect SQS messages as well as keys that protect your other AWS resources from a single location. To help you meet your regulatory and compliance requirements, AWS KMS logs every use of your encryption keys to AWS CloudTrail.
- Scale Elastically and Cost-Effectively: Amazon SQS makes use of Amazon Web Services to scale up and down in response to demand. You won’t have to worry about capacity planning or pre-provisioning because SQS scales flexibly with your application. The number of messages per queue is unrestricted, and standard queues offer nearly limitless throughput. When compared to the “always-on” model of self-managed messaging middleware, costs are based on usage, resulting in significant cost savings.
- Customization: Your queues don’t have to be identical; for example, a queue can have a default delay. You can either use Amazon Simple Storage Service (Amazon S3) or Amazon DynamoDB to store the contents of messages larger than 256 KB, with Amazon SQS holding a pointer to the Amazon S3 object, or you can split a large message into smaller messages.
Hevo Data, a Fully-managed Automated Data Pipeline solution, can help you automate, simplify & enrich your data flow from various AWS sources such as AWS S3 and AWS Elasticsearch in a matter of minutes. Hevo’s end-to-end Data Management offers streamlined preparation of Data Pipelines for your AWS account. Additionally, Hevo completely automates the process of not only extracting data from AWS S3 and AWS Elasticsearch but also enriching the data and transforming it into an analysis-ready form without having to write a single line of code.
Get Started with Hevo for Free
With Hevo’s out-of-the-box connectors and blazing-fast Data Pipelines, you can extract & aggregate data from 100+ Data Sources (including 40+ Free Sources) including AWS S3 and AWS Elasticsearch straight into your Data Warehouse, Database, or any destination. To further streamline and prepare your data for analysis, you can process and enrich Raw Granular Data using Hevo’s robust & built-in Transformation Layer without writing a single line of code!
Experience an entirely automated hassle-free Data Pipeline from AWS Services using Hevo. Try our 14-day full access free trial today!
What is AWS CLI?
The AWS Command Line Interface (CLI) is a centralized tool for managing your Amazon Web Services (AWS) accounts. You can control multiple AWS services from the command line and automate them using scripts with just one tool to download and configure.
The AWS CLI allows you to control and configure multiple AWS services while also implementing automation from a terminal session on your client.
When managing your AWS environment, the AWS CLI can assist you in unlocking additional potential. The AWS CLI is a unified tool that allows you to manage your AWS services from your terminal session. Multiple AWS services can be controlled from the command line and automated using scripts with just one tool to download and configure.
Understanding AWS CLI SQS
A user is connected to a computer program or operating system via a command-line interface. Users interact with a system or application using the CLI by typing in text. Following a visual prompt from the computer, the command is typed on a specific line. AWS SQS is a message queuing service that enables users to send and receive messages.
AWS CLI allows users to send and receive messages by using specific commands. Some of the commands are available in AWS CLI SQS are
AWS CLI SQS: add-permission
This command adds permission for a specific principal to a queue. It enables queue access to be shared. You have complete control over the queue’s access rights when you create it in AWS CLI SQS. Only you, as the queue’s owner, have the authority to grant or deny permissions.
Some things to keep in mind while using this command are:
- The command “AddPermission” creates a policy for you. To upload your policy, use “SetQueueAttributes “.
- A single Amazon SQS policy can have up to seven actions.
- You must deny permission to the “AddPermission,” “RemovePermission,” and “SetQueueAttributes” actions in your IAM policy to remove the ability to change queue permissions.
Some actions accept parameters in the form of a list. The param.n notation is used to specify these lists. The integers 1 to n are the values of n.
&AttributeName.1=first
&AttributeName.2=second
Synopsis
add-permission
--queue-url <value>
--label <value>
--aws-account-ids <value>
--actions <value>
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
Options
- –queue-url (string): The Amazon SQS queue to which permissions are added, as well as its URL. The names and URLs of queues are case-sensitive.
- –label (string): The permission you’re granting has a unique identifier (for example, AliceSendMessage ). There is a limit of 80 characters. Alphanumeric characters, hyphens (-), and underscores (_) are all permitted.
- –aws-account-ids (list): The principals’ Amazon Web Services account numbers who will be granted permission. For information on where to find the Amazon Web Services account ID.
- –actions (list): The action that the client wants the specified principal to be able to perform. The name of any action or “*” are valid values. When you specify SendMessage, DeleteMessage, or ChangeMessageVisibility for ActionName.n, you’ll also get access to the batch versions of those actions: SendMessageBatch, DeleteMessageBatch, and ChangeMessageVisibilityBatch.
- –cli-input-json | –cli-input-yaml (string):Reads arguments from the provided JSON string. The JSON string is formatted using the —generate-cli-skeleton format. If any other arguments are given on the command line, they will take precedence over the JSON values. Because the string will be taken literally, it is not possible to pass arbitrary binary values using a JSON-provided value. This command should not be used with —cli-input-yaml.
- –generate-cli-skeleton (string): Without making an API request, prints a JSON skeleton to standard output. Prints a sample input JSON that can be used as an argument for —cli-input-json if no value is provided or if the value is input. Similarly, yaml-input will print a sample YAML input that can be used with —cli-input-yaml if it is provided. It validates command inputs and returns a sample output JSON for that command if the value output is provided.
This is what syntax would look like:
"string" "string" …
Example
This example allows the AWS account to send messages to the queue specified. It demonstrates how to add permission to the queue.
aws sqs add-permission --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue --label SendMessagesFromMyQueue --aws-account-ids 12345EXAMPLE --actions SendMessage
AWS CLI SQS: change-message-visibility
This command in AWS CLI SQS sets a new value for the visibility timeout of a specified message in a queue. A message’s visibility timeout is set to 30 seconds by default. 0 seconds is the bare minimum. The maximum amount of time allowed is 12 hours.
Assume you have a message with a visibility timeout of five minutes. You call ChangeMessageVisibility with a 10-minute timeout after 3 minutes. To extend the visibility timeout to the maximum allowed time, keep calling ChangeMessageVisibility. Your request will be rejected if you try to extend the visibility timeout beyond the maximum.
When a message is sent to a queue by a producer but not yet received from the queue by a consumer, it is considered to be stored (that is, between states 1 and 2). There is no limit to the number of messages that can be saved. When a message is received from a queue by a consumer but not yet deleted from the queue, it is considered to be in flight (that is, between states 2 and 3). There is a limit to how many in-flight messages you can send.
Limits on in-flight messages have nothing to do with the unlimited number of stored messages.
Some things to keep in mind while using this command are:
- Amazon SQS returns an error if you try to set the VisibilityTimeout to a value greater than the maximum time left. The timeout on Amazon SQS is not automatically recalculated and increased to the maximum remaining time.
- When you change the visibility timeout for a specific message, unlike with a queue, the value is applied immediately and not saved in memory for that message. If you don’t delete a message after it’s been received, the message’s visibility timeout reverts to the original value (rather than the value you set using the ChangeMessageVisibility action) the next time it’s received.
Synopsis
change-message-visibility
--queue-url <value>
--receipt-handle <value>
--visibility-timeout <value>
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
Options
- –receipt-handle (string): The receipt handle for the message whose visibility timeout has been extended. The ” ReceiveMessage ” action returns this parameter.
- –visibility-timeout (integer): The message’s visibility timeout has a new value (in seconds). The values range from 0 to 43200. Maximum duration: 12 hours.
Example
The timeout visibility for the specified message is set to 10 hours (10 hours * 60 minutes * 60 seconds) in this example.
aws sqs change-message-visibility --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue --receipt-handle AQEBTpyI...t6HyQg== --visibility-timeout 36000
AWS CLI SQS: create-queue
This command in AWS CLI SQS creates a new FIFO or standard queue. In the request, you can include one or more attributes. Keep in mind the following:
- If the FifoQueue attribute is not specified, Amazon SQS creates a standard queue.
- If you don’t specify a value for an attribute, the queue will be created with the attribute’s default value.
- You must wait at least 60 seconds after deleting a queue before creating another with the same name.
To create a new queue successfully, you must provide a queue name that adheres to the queue limits and is unique within the scope of your queues.
Synopsis
create-queue
--queue-name <value>
[--attributes <value>]
[--tags <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
Options
- –attributes(map): A list of attributes and their associated values.
- –tags (map): To the specified Amazon SQS queue, add cost allocation tags. It’s not a good idea to add more than 50 tags to a queue. Tags are semantically meaningless. Tags are interpreted as character strings by Amazon SQS. Case matters when it comes to tags. A new tag with the same key as an existing tag will overwrite the existing tag.
Shorthand Syntax:
KeyName1=string,KeyName2=string
JSON Syntax:
{"string": "string"
...}
Example
This example creates a queue with the given name, sets the message retention period to three days (3 days * 24 hours * 60 minutes * 60 seconds), and assigns the queue’s dead letter queue to the given queue with a maximum receive count of 1,000 messages.
aws sqs create-queue --queue-name MyQueue --attributes file://create-queue.json
Input file (create-queue.json):
{
"RedrivePolicy": "{"deadLetterTargetArn":"arn:aws:sqs:us-east-1:80398EXAMPLE:MyDeadLetterQueue","maxReceiveCount":"1000"}",
"MessageRetentionPeriod": "259200"
}
Output
{
"QueueUrl": "https://queue.amazonaws.com/80398EXAMPLE/MyQueue"
OUTPUT:
QueueUrl -> (string) The created Amazon SQS queue’s URL.
AWS CLI SQS: delete-message
This command in AWS CLI SQS removes a specified message from the specified queue. Use the message’s ReceiptHandle to select the message to delete (not the MessageId which you receive when you send the message). Even if a message is locked by another consumer in AWS CLI SQS due to a visibility timeout setting, Amazon SQS can delete it from the queue. Amazon SQS deletes messages that have been in a queue for longer than the queue’s retention period.
Some things to keep in mind while using this command are:
- The ReceiptHandle is linked to a specific message receiving instance. The ReceiptHandle changes each time you receive a message if you receive it more than once. You must provide the most recently received ReceiptHandle for the message when using the DeleteMessage action (otherwise, the request succeeds, but the message might not be deleted).
- Even if you delete a message from a standard queue, it is possible to receive it again. If one of the servers that store a copy of the message is unavailable when you send the request to delete the message, this may happen on rare occasions. The copy is kept on the server and may be returned to you when you make another receive request. You should make sure that your application is idempotent, which means that receiving a message multiple times won’t cause any problems.
Synopsis
delete-message
--queue-url <value>
--receipt-handle <value>
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
Options
- –receipt-handle (string): The receipt handle for the message to be deleted.
Example
This example removes the specified message from the system.
aws sqs delete-message --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue --receipt-handle AQEBRXTo...q2doVA==
Loading data from AWS Sources such as AWS S3 and AWS Elasticsearch can be a mammoth task if the right set of tools is not leveraged. Hevo’s No-Code Automated Data Pipeline empowers you with a fully-managed solution for all your data collection, processing, and loading needs. Hevo’s native integration with S3 and Elasticsearch empowers you to transform and load data straight to a Data Warehouse such as Redshift, Snowflake, BigQuery & more!
This data loading lets you effortlessly connect to 100+ Sources (including 40+ free sources) and leverage Hevo’s blazing-fast Data Pipelines to help you seamlessly extract, transform, and load data to your desired destination such as a Data Warehouse.
Check out why Hevo is the Best:
- Schema Management: Hevo takes away the tedious task of schema management & automatically detects the schema of incoming data and maps it to the destination schema.
- Hevo Is Built To Scale: As the number of sources and the volume of your data grows, Hevo scales horizontally, handling millions of records per minute with very little latency.
- Incremental Data Load: Hevo allows the transfer of data that has been modified in real-time. This ensures efficient utilization of bandwidth on both ends.
- Live Support: The Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.
- Live Monitoring: Hevo allows you to monitor the data flow and check where your data is at a particular point in time.
SIGN UP HERE FOR A 14-DAY FREE TRIAL
AWS CLI SQS: delete-queue
This command in AWS CLI SQS deletes the queue specified by the QueueUrl, regardless of its content.
Some things to keep in mind while using this command:
- Keep in mind that if you use the DeleteQueue action, any messages in the queue will be deleted as well.
When you delete a queue, it can take up to 60 seconds to complete. During the 60 seconds, you might be able to send requests to that queue.
For example, a “ SendMessage “ request might succeed, but the queue and the message you sent will be gone after 60 seconds.
You must wait at least 60 seconds after deleting a queue before creating another with the same name.
Synopsis
delete-queue
--queue-url <value>
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
Options
- –queue-url (string): The Amazon SQS queue you want to delete’s URL. The case is important in queue URLs and names.
Example
The specified queue is deleted in this example.
aws sqs delete-queue --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyNewerQueue
AWS CLI SQS: get-queue-url
The URL of an existing Amazon SQS queue is returned using this command in AWS CLI SQS.
Use the QueueOwnerAWSAccountId parameter to specify the account ID of the queue’s owner to access a queue that belongs to another AWS account. The owner of the queue must permit you to join it.
Synopsis
get-queue-url
--queue-name <value>
[--queue-owner-aws-account-id <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
Options
- –queue-name (string): The name of the queue for which the URL needs to be retrieved. There is a limit of 80 characters. Alphanumeric characters, hyphens (-), and underscores (_) are all valid values. The names and URLs of queues are case-sensitive.
- –queue-owner-aws-account-id (string): The account ID of the account that created the queue on Amazon Web Services.
Example
The URL of the specified queue is obtained in this example:
aws sqs get-queue-url --queue-name MyQueue
Output
{
"QueueUrl": "https://queue.amazonaws.com/80398EXAMPLE/MyQueue"
}
OUTPUT:
QueueUrl -> (string) The queue’s URL.
AWS CLI SQS: receive-message
This command in AWS CLI SQS enables the specified queue to be used to retrieve one or more messages (up to ten). Long-poll support is enabled by the WaitTimeSeconds parameter.
A weighted random set of machines is sampled on a ReceiveMessage call in the short poll mode, which is the default behavior. As a result, only the messages from the machines that have been sampled are returned. If there are fewer than 1,000 messages in the queue, you will most likely receive fewer messages per ReceiveMessage call than you requested. You might not receive any messages in a particular ReceiveMessage response if the number of messages in the queue is extremely small. Repeat the request if this happens.
The following information is included in the response for each message:
- The body of the message.
- The message body’s MD5 digest. RFC1321 contains information on MD5.
- When you sent the message to the queue, you were given a MessageId.
- The handle on the receipt.
- The attributes of the message.
- The attributes of the message are MD5 digested.
Some things to keep in mind while using this command are:
- When deleting a message, you must provide the receipt handle as an identifier. The VisibilityTimeout parameter can be included in your request. The parameter affects the messages returned by Amazon SQS in the response. If you don’t include the parameter, the returned messages will use the queue’s overall visibility timeout.
- A failed receive is defined as a message that has not been deleted or whose visibility has not been extended before the visibility timeout expires. The message might be sent to the dead-letter queue, depending on the queue’s configuration.
Synopsis
receive-message
--queue-url <value>
[--attribute-names <value>]
[--message-attribute-names <value>]
[--max-number-of-messages <value>]
[--visibility-timeout <value>]
[--wait-time-seconds <value>]
[--receive-request-attempt-id <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
Options
- –queue-url (string): The Amazon SQS queue from which messages are received is identified by its URL. The names and URLs of queues are case-sensitive.
- –attribute-names (list): Each message must have a list of attributes that must be returned with it.
- –message-attribute-names (list): The message attribute’s name, where N is the index.
- The underscore (_), hyphen (-), and period characters are allowed in the name (. ).
- The name must be case-sensitive and unique among all of the message’s attribute names.
- AWS-reserved prefixes such as AWS. or Amazon must not be used in the name (or any casing variants).
- A period (.) must not appear at the beginning or end of the name, nor should there be any periods in a row (.. ).
- The name has a maximum length of 256 characters.
- When using ReceiveMessage, you can send a list of attribute names to receive, or specify All or.* in your request to return all of the attributes. All message attributes that begin with a prefix, such as bar.*, can also be used.
- –max-number-of-messages (integer): This is the maximum number of messages that will be returned. More messages than this value are never returned by Amazon SQS (however, fewer messages might be returned). 1 to 10 are valid values. 1 is the default value.
- –visibility-timeout (integer): After being retrieved by a ReceiveMessage request, the duration (in seconds) for which the received messages are hidden from subsequent retrieve requests.
- –wait-time-seconds (integer): The time it takes for a message to arrive in the queue before the call returns (in seconds). The call returns faster than WaitTimeSeconds if a message is available. If no messages are available after the wait time has expired, the call is completed with an empty message list.
- –receive-request-attempt-id (string): Only FIFO (first-in-first-out) queues are affected by this parameter. ReceiveMessage calls are deduplicated using this token. If you receive a generic error instead of a response after performing a ReceiveMessage action, you can retry the same action with an identical ReceiveRequestAttemptId to retrieve the same set of messages, even if their visibility timeout has not yet expired.
Syntax:
"string" "string" …
Example
This example receives up to ten messages and returns all of their attributes:
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue --attribute-names All --message-attribute-names All --max-number-of-messages 10
Output
{
"Messages": [
{
"Body": "My first message.",
"ReceiptHandle": "AQEBzbVv...fqNzFw==",
"MD5OfBody": "1000f835...a35411fa",
"MD5OfMessageAttributes": "9424c491...26bc3ae7",
"MessageId": "d6790f8d-d575-4f01-bc51-40122EXAMPLE",
"Attributes": {
"ApproximateFirstReceiveTimestamp": "1442428276921",
"SenderId": "AIDAIAZKMSNQ7TEXAMPLE",
"ApproximateReceiveCount": "5",
"SentTimestamp": "1442428276921"
},
"MessageAttributes": {
"PostalCode": {
"DataType": "String",
"StringValue": "ABC123"
},
"City": {
"DataType": "String",
"StringValue": "Any City"
}
}
}
]
}
OUTPUT:
Messages -> (list)
A list of messages.
(structure)
An Amazon SQS message.
MessageId -> (string)
The message's unique identifier. For an extended period, a MessageId is considered unique across all Amazon Web Services accounts.
ReceiptHandle -> (string)
A unique identifier for the act of receiving a message. Every time you receive a message, you will be given a new receipt handle. When deleting a message, you must provide the message's last received receipt handle.
MD5OfBody -> (string)
The MD5 digest of the message body string that isn't encoded with the URL.
Body -> (string)
The message’s contents (not URL-encoded).
Attributes -> (map)
The attributes requested in " ReceiveMessage " are mapped to their values in this map. Attributes that are supported include:
ApproximateReceiveCount
ApproximateFirstReceiveTimestamp
MessageDeduplicationId
MessageGroupId
SenderId
SentTimestamp
SequenceNumber
The epoch time in milliseconds is represented by ApproximateFirstReceiveTimestamp and SentTimestamp, which are returned as integers.
Name -> (string)
Value -> (string)
MD5OfMessageAttributes -> (string)
The MD5 digest of the message attribute string that hasn't been encoded with a URL. This attribute can be used to ensure that Amazon SQS correctly received the message. Before creating an MD5 digest, Amazon SQS URL decodes the message.
MessageAttributes -> (map)
Each message attribute consists of a Name, Type, and Value.
Name -> (string)
Value -> (structure)
The message attribute value is specified by the user. The Value attribute has the same content restrictions as the message body for string data types.
The message body, name, type, and value must not be null or empty. The message size restriction encompasses all elements of the message attribute, including Name, Type, and Value (256 KB or 262,144 bytes).
StringValue -> (string)
Strings are Unicode with UTF-8 binary encoding.
Any binary data, such as compressed data, encrypted data, or images, can be stored in binary type attributes.
StringListValues -> (list)
Not implemented. Reserved for future use.
(string)
BinaryListValues -> (list)
Not implemented. Reserved for future use.
(blob)
DataType -> (string)
The following logical data types are supported by Amazon SQS: String, Number, and Binary. StringValue is required for the Number data type.
Custom labels can also be added.
AWS CLI SQS: send-message
This sends a message to the queue specified.
Only XML, JSON, and unformatted text are allowed in a message. #x9 | #xA | #xD | #x20 to #xD7FF | #xE000 to #xFFFD | #x10000 to #x10FFFF Unicode characters are allowed.
Characters that do not appear on this list will be rejected.
Synopsis
send-message
--queue-url <value>
--message-body <value>
[--delay-seconds <value>]
[--message-attributes <value>]
[--message-system-attributes <value>]
[--message-deduplication-id <value>]
[--message-group-id <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
Options
- –queue-url (string): The Amazon SQS queue to which a message is delivered. The names and URLs of queues are case-sensitive.
- –message-body (string): The message that should be sent. One character is the smallest size. The file size limit is 256 KB.
- –delay-seconds (integer): The amount of time, in seconds, that a message should be delayed. 0 to 900 are valid values. Time limit: 15 minutes. After the delay period is over, messages with a positive DelaySeconds value become available for processing. If you don’t specify a value, the queue’s default value is used.
- –message-attributes (map): Each message attribute has three parts: a Name, a Type, and a Value.
- –message-system-attributes (map): The attribute of the message system to send. A Name, Type, and Value are assigned to each message system attribute.
- –message-deduplication-id (string): Only FIFO (first-in-first-out) queues are affected by this parameter. The token is used to prevent duplicate messages from being sent. Any messages sent with the same MessageDeduplicationId are accepted successfully but not delivered during the 5-minute deduplication interval if a message with that MessageDeduplicationId is sent successfully.
- –message-group-id (string): Only FIFO (first-in, first-out) queues are affected by this parameter. The tag indicates whether or not a message is part of a specific message group. FIFO processing is used to process messages that belong to the same message group (however, messages in different message groups might be processed out of order). Use MessageGroupId values in a single queue to interleave multiple ordered streams (for example, session data for multiple users). Multiple consumers can process the queue in this scenario, but each user’s session data is processed FIFO.
Shorthand Syntax:
KeyName1=StringValue=string,BinaryValue=blob,StringListValues=string,string,BinaryListValues=blob,blob,DataType=string,KeyName2=StringValue=string,BinaryValue=blob,StringListValues=string,string,BinaryListValues=blob,blob,DataType=string
Where valid key names are:
AWSTraceHeader
JSON Syntax:
{"AWSTraceHeader": {
"StringValue": "string",
"BinaryValue": blob,
"StringListValues": ["string", ...],
"BinaryListValues": [blob, ...],
"DataType": "string"
}
...}
Example
This example sends a message to the specified queue, with the specified message body, delay period, and message attributes.
aws sqs send-message --queue-url https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyQueue --message-body "Information about the largest city in Any Region." --delay-seconds 10 --message-attributes file://send-message.json
Input file (send-message.json):
{
"City": {
"DataType": "String",
"StringValue": "Any City"
},
"Greeting": {
"DataType": "Binary",
"BinaryValue": "Hello, World!"
},
"Population": {
"DataType": "Number",
"StringValue": "1250800"
}
}
Output
{
"MD5OfMessageBody": "51b0a325...39163aa0",
"MD5OfMessageAttributes": "00484c68...59e48f06",
"MessageId": "da68f62c-0c07-4bee-bf5f-7e856EXAMPLE"
}
OUTPUT:
MD5OfMessageBody -> (string)
The MD5 digest of the message body string that is not URL encoded. This attribute can be used to check that Amazon SQS received the message correctly. Before generating the MD5 digest, Amazon SQS URL decodes the message.
MD5OfMessageAttributes -> (string)
The non-URL-encoded message attribute string's MD5 digest. This attribute can be used to ensure that Amazon SQS received the message correctly. Before creating the MD5 digest, Amazon SQS URL decodes the message.
MD5OfMessageSystemAttributes -> (string)
The MD5 digest of the message system attribute string that is not encoded with a URL. This attribute can be used to ensure that Amazon SQS correctly received the message. Before creating an MD5 digest, Amazon SQS URL decodes the message.
MessageId -> (string)
The MessageId of the message sent to the queue is stored in this attribute.
SequenceNumber -> (string)
Only FIFO (first-in-first-out) queues are affected by this parameter.
Each message is assigned a large, non-consecutive number by Amazon SQS.
SequenceNumber has a length of 128 bits. For a given MessageGroupId, the SequenceNumber keeps increasing.
Conclusion
This blog talks about the working of AWS CLI SQS and how messages can be sent and received using the AWS command-line interface. It also describes the key benefits of AWS SQS.
Master the use of AWS SQS’s DeleteMessage feature to efficiently manage your message queue. Learn more about its functionality in SQS DeleteMessage.
visit our website to explore hevo[/hevoButton]
Hevo Data, a No-code Data Pipeline provides you with a consistent and reliable solution to manage data transfer between a variety of sources and a wide variety of Desired Destinations, with a few clicks. Hevo Data with its strong integration with 150+ sources (including 40+ free sources) allows you to not only export data from your desired data sources & load it to the destination of your choice, but also transform & enrich your data to make it analysis-ready so that you can focus on your key business needs and perform insightful analysis.
Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand. You can also have a look at the unbeatable pricing that will help you choose the right plan for your business needs.
Harshitha is a dedicated data analysis fanatic with a strong passion for data, software architecture, and technical writing. Her commitment to advancing the field motivates her to produce comprehensive articles on a wide range of topics within the data industry.