aws.sqs
Module aws.sqs

ballerinax/aws.sqs
Overview
Ballerina connector for Amazon SQS connects the Amazon SQS API via Ballerina language with ease. It provides capability to perform operations related to queues and messages.
This module supports Amazon SQS API version 2012-11-05.
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create an AWS account
- Obtain tokens - Follow this link to obtain Access key ID, Secret access key, Region and Account number from navigation pane
Users
and selectingSecurity credentials
tab.
Quickstart
To use the Amazon SQS connector in your Ballerina application, update the .bal file as follows:
Step 1: Import connector
Import the ballerinax/aws.sqs module into the Ballerina project as follows.
Step 2: Create a new connector instance
You can now enter the credentials in the SQS client configuration and create the SQS client by passing the configuration as follows.
Step 3: Invoke connector operation
-
You can create a queue in SQS as follows with
createQueue
method for a preferred queue name and the required set of attributes. -
Use
bal run
command to compile and run the Ballerina program.
Clients
aws.sqs: Client
Ballerina Amazon SQS connector provides the capability to access Amazon SQS API. This connector lets you to perform operations related to manage queues, send and receive messages.
Constructor
Initializes the connector. During initialization you have to pass API credentials. Create a AWS account and obtain tokens following this guide.
init (ConnectionConfig config)
- config ConnectionConfig - Configuration for the connector
createQueue
function createQueue(string queueName, QueueAttributes? attributes, map<string>? tags) returns CreateQueueResponse|error
Creates a new queue in SQS.
Parameters
- queueName string - Name of the queue to be created
- attributes QueueAttributes? (default ()) - Queue related attribute parameters
Return Type
- CreateQueueResponse|error - If success, URL of the created queue, else returns error
sendMessage
function sendMessage(string messageBody, string queueResourcePath, MessageAttribute[]? messageAttributes, string? messageGroupId, string? messageDeduplicationId, int? delaySeconds) returns SendMessageResponse|error
Send a new message to a SQS queue.
Parameters
- messageBody string - Message body string to be sent
- queueResourcePath string - Resource path to the queue from the host address. e.g.: /610968236798/myQueue.fifo
- messageAttributes MessageAttribute[]? (default ()) - Message attributes for sending a message
- messageGroupId string? (default ()) - Message group which a message belongs. only applicable to FIFO queues
- messageDeduplicationId string? (default ()) - Message deduplicationId ID. only applicable to FIFO queues
- delaySeconds int? (default ()) - Length of time for which to delay a specific message. On FIFO queue can't set for a message
Return Type
- SendMessageResponse|error - If success, details of the sent message, else returns error
receiveMessage
function receiveMessage(string queueResourcePath, int? maxNumberOfMessages, int? visibilityTimeout, int? waitTimeSeconds, string[]? attributeNames, string[]? messageAttributeNames, string? receiveRequestAttemptId) returns ReceiveMessageResponse|error
Receive message(s) from the queue.
Parameters
- queueResourcePath string - Resource path to the queue from the host address. e.g.: /610968236798/myQueue.fifo
- maxNumberOfMessages int? (default ()) - Maximum number of messages returned. Possible values are 1-10. Default is 1
- visibilityTimeout int? (default ()) - Duration (in seconds) that messages are hidden from subsequent requests
- waitTimeSeconds int? (default ()) - Wait time in seconds
- attributeNames string[]? (default ()) - List of attributes that need to be returned along with each message
- messageAttributeNames string[]? (default ()) - Name of the message attribute
- receiveRequestAttemptId string? (default ()) - Deduplication token of receive message calls. only applicable to FIFO queues
Return Type
- ReceiveMessageResponse|error - If success, details of the received message, else returns error
deleteMessage
function deleteMessage(string queueResourcePath, string receiptHandle) returns DeleteMessageResponse|error
Delete message(s) from the queue for a given receiptHandle.
Parameters
- queueResourcePath string - Resource path to the queue from the host address. e.g.: /610968236798/myQueue.fifo
- receiptHandle string - Receipt Handle parameter for the message(s) to be deleted
Return Type
- DeleteMessageResponse|error - Details of the deleted message when the message(s) were successfully deleted or whether an error occurred
deleteQueue
function deleteQueue(string queueResourcePath) returns DeleteQueueResponse|error
Delete queue(s).
Parameters
- queueResourcePath string - Resource path to the queue from the host address. e.g.: /610968236798/myQueue.fifo
Return Type
- DeleteQueueResponse|error - Details of the deleted queue when the queue(s) were successfully deleted or whether an error occurred
Functions
splitString
Records
aws.sqs: ConnectionConfig
Represents the AWS SQS Connector configurations.
Fields
- Fields Included from * ConnectionConfig
- auth AuthConfig
- httpVersion HttpVersion
- http1Settings ClientHttp1Settings
- http2Settings ClientHttp2Settings
- timeout decimal
- forwarded string
- poolConfig PoolConfiguration
- cache CacheConfig
- compression Compression
- circuitBreaker CircuitBreakerConfig
- retryConfig RetryConfig
- responseLimits ResponseLimitConfigs
- secureSocket ClientSecureSocket
- proxy ProxyConfig
- validation boolean
- anydata...
- auth never? -
- accessKey string - AccessKey of Amazon Account
- secretKey string - SecretKey of Amazon Account
- region string - Region of SQS Queue
aws.sqs: CreateQueueResponse
Create queue response
Fields
- createQueueResult CreateQueueResult - Result of queue creation
- responseMetadata ResponseMetadata - Response metadata
aws.sqs: CreateQueueResult
Create queue result
Fields
- queueUrl string - Url of the queue
aws.sqs: DeleteMessageResponse
Delete message response
Fields
- responseMetadata ResponseMetadata - Response metadata
aws.sqs: DeleteQueueResponse
Delete queue response
Fields
- responseMetadata ResponseMetadata - Response metadata
aws.sqs: ErrorDetail
Holds the details of an AWS SQS error
Fields
- message string - Specific error message for the error
- cause error? - Cause of the error; If this error occurred due to another error (Probably from another module)
aws.sqs: InboundMessage
Response message for receiveMessage method
Fields
- body string - Message body got from receiveMessage method
- md5OfBody string - MD5 of message body got from receiveMessage method
- md5OfMessageAttributes string - MD5 of message attributes got from receiveMessage method
- messageAttributes map<MessageAttributeValue> - Message Attribute parameters got from receiveMessage method
- messageId string - Message ID for the message got from receiveMessage method
- receiptHandle string - Receipt Handle of the message got from receiveMessage method
aws.sqs: MessageAttribute
Data defined in a message attribute
Fields
- keyName string - Key name
- value MessageAttributeValues - Message attribute values
aws.sqs: MessageAttributeValue
Data parameters defined in a MessageAttributeValue parameter
Fields
- binaryListValues string[] - Array of Base64-encoded binary data objects. Reserved for future use.
- binaryValue string - Base64-encoded binary data object. Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.
- dataType string - Supports the following logical data types: String, Number, and Binary. For the Number data type, you must use StringValue.
- stringListValues string[] - Array of strings. Reserved for future use.
- stringValue string - String values of Unicode with UTF-8 binary encoding.
aws.sqs: MessageAttributeValues
Data defined in a message attribute value
Fields
- stringValue string - String value
- dataType string - Data type
aws.sqs: OutboundMessage
Response message for sendMessage method
Fields
- md5OfMessageAttributes string? - MD5 of message attributes sent to sendMessage method
- md5OfMessageBody string - MD5 of message body sent to sendMessage method
- messageId string - Message ID for the message sent to sendMessage method
- sequenceNumber string? - Sequence number of the sent message
aws.sqs: QueueAttributes
Queue attribute
Fields
- delaySeconds int? - Delay seconds
- maximumMessageSize int? - Maximum message size
- messageRetentionPeriod int? - Time Amazon SQS retains a message
- policy string? - Valid AWS queue policy
- receiveMessageWaitTimeSeconds int? - Time receiveMessage action waits for a message to arrive
- visibilityTimeout int? - Visibility timeout for the queue
- contentBasedDeduplication boolean? - Enables content-based deduplication
- fifoQueue boolean? - Designates a queue as FIFO
- kmsMasterKeyId string? - ID of an AWS managed customer master key
- kmsDataKeyReusePeriodSeconds int? - Time that Amazon SQS can reuse a data key to encrypt or decrypt messages
- deduplicationScope string? - Specifies whether message deduplication occurs at the message group or queue level
- fifoThroughputLimit string? - Specifies whether the FIFO queue throughput quota applies to the entire queue or per message group
- redrivePolicy json? - Parameters for the dead-letter queue functionality of the source queue
- redriveAllowPolicy json? - Permissions for the dead-letter queue redrive permission
aws.sqs: ReceiveMessageResponse
Receive message response
Fields
- receiveMessageResult ReceiveMessageResult - Result of receive message
- responseMetadata ResponseMetadata - Response metadata
aws.sqs: ReceiveMessageResult
Receive message result
Fields
- message InboundMessage[] - Collection of received messages
aws.sqs: ResponseMetadata
Response metadata
Fields
- requestId string - Request id of response
aws.sqs: SendMessageResponse
Send message response
Fields
- sendMessageResult SendMessageResult - Result of send message
- responseMetadata ResponseMetadata - Response metadata
aws.sqs: SendMessageResult
Send message result
Fields
- md5OfMessageAttributes string? - MD5 of message attributes sent to sendMessage method
- md5OfMessageBody string - MD5 of message body sent to sendMessage method
- messageId string - Message ID for the message sent to sendMessage method
- sequenceNumber string? - Sequence number of the sent message