Queue
Reference doc for the `sst.aws.Queue` component.
The Queue
component lets you add a serverless queue to your app. It uses Amazon SQS.
Create a queue
Make it a FIFO queue
You can optionally make it a FIFO queue.
Add a subscriber
Link the queue to a resource
You can link the queue to other resources, like a function or your Next.js app.
Once linked, you can send messages to the queue from your function code.
Constructor
Parameters
-
name
string
-
args?
QueueArgs
-
opts?
ComponentResourceOptions
QueueArgs
fifo?
Type Input
<
boolean
>
Default false
FIFO or first-in-first-out queues are designed to guarantee that messages are processed exactly once and in the order that they are sent.
transform?
transform.queue?
Properties
arn
Type Output
<
string
>
The ARN of the SQS queue.
nodes
nodes.queue
Type Queue
The Amazon SQS queue.
url
Type Output
<
string
>
The SQS queue URL.
SDK
The following are accessible through the SDK at runtime.
url
Type string
The SQS queue URL.
Methods
subscribe
Parameters
The function that’ll be notified.subscriber
string
|
FunctionArgs
Configure the subscription.args?
QueueSubscriberArgs
Returns Output
<
QueueLambdaSubscriber
>
Subscribe to this queue.
Add a filter to the subscription.
Customize the subscriber function.
static subscribe
Parameters
The ARN of the SQS queue to subscribe to.queueArn
Input
<
string
>
The function that’ll be notified.subscriber
string
|
FunctionArgs
Configure the subscription.args?
QueueSubscriberArgs
Returns Output
<
QueueLambdaSubscriber
>
Subscribe to an SQS queue that was not created in your app.
For example, let’s say you have an existing SQS queue with the following ARN.
You can subscribe to it by passing in the ARN.
Add a filter to the subscription.
Customize the subscriber function.
QueueSubscriberArgs
filters?
Type Input
<
Input
<
Record
<
string
, any
>
>
[]
>
Filter the records that’ll be processed by the subscriber
function.
You can pass in up to 5 different filter policies. These will logically ORed together. Meaning that if any single policy matches, the record will be processed. Learn more about the filter rule syntax.
For example, if you Queue contains records in this JSON format.
To process only those records where the RequestCode
is BBBB
.
And to process only those records where RecordNumber
greater than 9999
.
transform?
Type Object
Transform how this component creates its underlying resources.
transform.eventSourceMapping?
Type EventSourceMappingArgs
|
(
args
:
EventSourceMappingArgs
=>
void
)
Transform the Lambda Event Source Mapping resource.