This Linx 6 template demonstrates how to retrieve messages from an Amazon SQS queue, store them in a database, and subsequently delete them from the queue. It is designed to integrate with the AWS CLI and provides a low-code approach to polling and processing queue messages within Linx.
Messages are stored in a SQLite database by default, although this can be modified to suit other storage systems.
- AWS CLI must be installed and configured on the local machine. The solution depends on it for SQS access.
- AWS SQS must be set up with a user that has the necessary permissions.
Refer to the AWS CLI Version 2 installation guide to install the AWS CLI.
- Update Settings
The following settings are required for the template to function:
Setting | Description |
---|---|
AWSAccessKey |
AWS Access Key |
AWSSecret |
AWS Secret Access Key |
AWSSQSUrl |
Full URL of the SQS queue to poll |
DBConnection |
Connection string for the SQLite database (e.g. Driver={SQLite3 ODBC Driver};Database=C:\SQSWhisperer.db; ) |
AWSCMD |
Path to the AWS CLI executable, used if not globally available on the system PATH |
AWSRegion |
Region where the SQS queue is hosted |
SQSVisibilityTimeout |
Duration (in seconds) that a message is hidden after being read (default is 30 seconds) |
SQSMaxNumberOfMessages |
Maximum number of messages to retrieve per poll (maximum allowed by AWS is 10) |
- Configure AWS CLI
Use the RunAWSConfig
function to set up the AWS CLI. This sets up access credentials required to interact with AWS SQS. Once configured, the CLI stores the credentials and they do not need to be reset unless expired.
-
Run
RunAWSConfig
This function configures the AWS CLI for use with SQS. It must be executed at least once before attempting to read messages.
-
Run
PollQueue
This function:
- Retrieves up to
SQSMaxNumberOfMessages
from the SQS queue. - For each message, checks if it already exists in the database.
- If not found, inserts the message.
- If found, updates the existing record.
- Deletes the message from the queue using
DeleteMessage
.
- Retrieves up to
Function Name | Description |
---|---|
RunAWSConfig |
Ensures AWS CLI configuration remains valid. It can be run multiple times without adverse effects. If not run and credentials expire, SQS access will fail. |
ReadSQSQueue |
Retrieves messages from the SQS queue based on the SQSMaxNumberOfMessages setting. Applies the SQSVisibilityTimeout to temporarily hide read messages. |
DeleteMessage |
Deletes a message from the SQS queue. |
PollQueue |
Retrieves and stores messages in the database. Uses ReadSQSQueue and DeleteMessage . |
SendToSQSQueue |
Sends a message to the queue. Intended for testing purposes only. |
Service Name | Description |
---|---|
RunAWSConfig |
Runs RunAWSConfig three times daily at 07:45:00 , 12:45:00 , and 19:45:00 to maintain CLI credentials. |
PollQueue |
Executes every 1 minute to check for and process new messages. Calls the PollQueue function. |
- The AWS CLI may fail silently. For example, attempting to delete a non-existent message might not raise an error.
- Ensure the
AWS CLI
path is correctly specified in theAWSCMD
setting if it is not available globally.