Skip to content

A Linx 6 solution template that demonstrates how to poll messages from an Amazon SQS queue using the AWS CLI. Messages are read from the queue, stored in a SQLite database, and deleted from the queue after processing. Includes support for message deduplication, visibility timeouts, and periodic configuration renewal.

Notifications You must be signed in to change notification settings

linx-software/AWS-SQS-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

AWS SQS Polling Template

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.


Prerequisites

  • 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.


Setup

  1. 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)
  1. 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.


Usage

  1. Run RunAWSConfig

    This function configures the AWS CLI for use with SQS. It must be executed at least once before attempting to read messages.

  2. 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.

Functions

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.

Services

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.

Notes

  • 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 the AWSCMD setting if it is not available globally.

About

A Linx 6 solution template that demonstrates how to poll messages from an Amazon SQS queue using the AWS CLI. Messages are read from the queue, stored in a SQLite database, and deleted from the queue after processing. Includes support for message deduplication, visibility timeouts, and periodic configuration renewal.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published