Amazon SQS – Fully managed message queues
Fully managed message queues for microservices, distributed systems, and serverless applications.
Amazon Simple Queue Service (Amazon SQS) offers a secure, durable, and available hosted queue that lets you integrate and decouple distributed software systems and components. Amazon SQS offers common queue constructs such as dead-letter queues and cost allocation tags. It provides a generic web services API and it can be accessed by any programming language that the AWS SDK supports.
Amazon SQS supports both standard and FIFO queues.
Setup:
Sign-up for an AWS account and setup the SQS queue(s). You must set up at least one queue which will act as the default for messages from PubNub.
Sign-up for a PubNub account, if you don't have one already.
Import the Integration Block into your PubNub account. You can choose to add this to an existing application or create a new one.
Configure the Integration Block module code, connecting it to your AWS account:
Create a Secret in PubNub Vault, named AWS_ACCESS_KEY_ID, with value equal to your AWS Access Key ID for this service.
Create a Secret in PubNub Vault, named AWS_SECRET_KEY, with value equal to your AWS Secret Key for this service.
Create a Secret in PubNub Vault, named AWS_REGION, with value equal to your AWS Region for the target queue .
Create a Secret in PubNub Vault, named AWS_ACCOUNT_NUMBER, with value equal to your AWS Account ID for this service.
Create a Secret in your PubNub Vault, named AWS_DEFAULT_QUEUE_NAME, with the name of the AWS queue that you created in step 1.
Start the Integration Block module.
Try a test message (you can click on
Publish
to do this).
How it works:
After importing the Integration Block to your account, a new function called “Amazon SQS v2” will be setup to listen to a specific PubNub channel (CHANNEL-to-send-to-SQS), but you can configure it to listen to all channels or a subset, using wildcards, e.g. chat.*.
Whenever your app publishes a message on the channel that you specified, the function will write the message body to the AWS SQS queue that you specified in the vault as AWS_DEFAULT_QUEUE_NAME.
You can also overwrite the default queue name specified in the function code by publishing messages with additional metadata that specifies a different queue name to use.
The following example describes how to set the metadata so that the message published is sent to a queue named “my_dyanamic_queue”:
{ "functions": { "aws-sqs-v2": { "input": { "TARGET_QUEUE_NAME": "my_dyanamic_queue" } } } }
Your metadata should include a JSON object that matches this format, with whatever value you need as the value for the TARGET_QUEUE_NAME field. Examples of how to publish messages with metadata can be found in the Publish documentation.