Stand with Ukraine flag
Try it now Pricing
Community Edition
Community Edition Professional Edition Cloud Edge PE Edge IoT Gateway License Server Trendz Analytics Mobile Application PE Mobile Application MQTT Broker
Getting Started Documentation Devices Library Guides Installation Architecture API FAQ

SQS Plugin

Doc info icon
Important note

Please note that this guide is for ThingsBoard versions prior v2.0.

Old rules and plugins functionality is replaced by new rule engine components (rule chains and rule nodes).

Please review new rule engine documentation to learn how to adopt new functionality.

We are doing our best to modify this guide to v2.0 components. Contributions are welcome.

Overview

SQS plugin is responsible for sending messages to Amazon Web Services Simple Queue Service queues triggered by specific rules

Configuration

SQS Plugin has the following configuration parameters:

  • Access Key ID
  • Secret Access Key
  • Region

Access Key ID and Secret Access Key are the credentials of an AWS IAM User with programmatic access. More information on AWS access keys can be found here

Region must correspond to the one in which the SQS Queue(s) are created. Current list of AWS Regions can be found here

Server-side API

This plugin does not provide any server-side API.

Example

In this example, we are going to demonstrate how you can configure this extension to be able to send a message to both SQS Sandard and FIFO queues every time new telemetry message for the device arrives.

Prerequisites before contining Kafka extension configuration:

  • AWS IAM User is created and Access Key ID/Secret Access Key are obtained
  • SQS Standard Queue is created
  • SQS FIFO Queue is created
  • ThingsBoard is up and running

The information on how to create SQS Queues can be found here

SQS Plugin Configuration

Let’s configure SQS plugin first. Go to Plugins menu and create new plugin:

image

image

Make sure to replace <$YOUR_ACCESS_KEY_ID> and <$YOUR_SECRET_ACCESS_KEY> placeholders with the actual values and set the right region.

Click on ‘Activate’ plugin button:

image

SQS Standard Queue Rule Configuration

SQS Standard Queue does not preserve the order in which messages have arrived and ensures At-Least-Once message delivery.

In order to create SQS Standard Queue Rule, go to Rules screen and click ‘Add New rule’ button.

image

Add filter for POST_TELEMETRY message type:

image

Click ‘Add’ button to add filter.

Then select ‘SQS Plugin’ in the drop-down box for the Plugin field:

image

Add action that will send temperature telemetry of device to the particular SQS Standard Queue:

image

Click ‘Add’ button and then activate Rule.

image

Sending Temperature Telemetry

Now you can send Telemetry message that contains ‘temp’ telemetry for any of your devices:

1
{"temp":73.4}

Here is an example of a command that publish single telemetry message to locally installed ThingsBoard:

1
mosquitto_pub -d -h "localhost" -p 1883 -t "v1/devices/me/telemetry" -u "$ACCESS_TOKEN" -m "{'temp':73.4}"

Now you should be able to see the message available in your SQS Standard Queue through AWS console:

image

SQS FIFO Queue Rule Configuration

SQS FIFO Queue maintains First-In-First-Out order Per Message Group ID and ensures exactly one processing. ThingsBoard SQS Plugin uses Device ID as Message Group ID when sending a message to SQS FIFO Queue. It means that FIFO order will be maintained on per-device basis.

SQS FIFO Queue Rule configation is very similar to the SQS Standard Queue configuration with subtle differences.

In order to create SQS FIFO Queue Rule, go to Rules screen and click ‘Add New rule’ button.

image

Add filter for POST_TELEMETRY message type:

image

Click ‘Add’ button to add filter.

Then select ‘SQS Plugin’ in the drop-down box for the Plugin field:

image

Add action that will send temperature telemetry of device to the particular SQS FIFO Queue:

image

Click ‘Add’ button and then activate Rule.

image

Sending Temperature Telemetry

Now you can send Telemetry message that contains ‘temp’ telemetry for any of your devices:

1
{"temp":68.3}

Here is an example of a command that publish single telemetry message to locally installed ThingsBoard:

1
mosquitto_pub -d -h "localhost" -p 1883 -t "v1/devices/me/telemetry" -u "$ACCESS_TOKEN" -m "{'temp':68.3}"

Now you should be able to see the message available in your SQS FIFO Queue through AWS console:

image