Sends to and receives from Amazon SQS queues, or any service that speaks
SQS's JSON protocol (ElasticMQ, LocalStack). One step does one
operation:
sendsends one message to the queue: its body is the step'ssource(the side's body by default), withattributes(String message attributes), and, for a FIFO queue,message_group_idanddeduplication_id, ordelay_seconds;receivelong-polls the queue for up tomax_messagesmessages, waiting up towait_time_sfor the first, and hides each from other consumers for the queue's visibility timeout, orvisibility_timeout_s. Its outputs are the messages (messages,messagethe first,count). A poll that brings none ends the pipeline with nothing (when_empty: "return", the default), which a trigger's run counts as empty, or goes on with no messages ("continue"). Withdelete: "immediate"the messages are deleted as they arrive (at most once); the default,"manual", leaves that to later steps;deletedeletes one received message by itsreceipt_handle;releasemakes a received message visible again aftervisibility_timeout_s(default 0: at once), so the queue delivers it again;countsreads the queue's approximate counts: the messages waiting (waiting), received and not yet deleted (in_flight) and delayed (delayed).%{"operation" => "receive", "queue_url" => "https://sqs.eu-north-1.amazonaws.com/123456789012/orders", "access_key_id" => "{{AWS_ACCESS_KEY_ID}}", "secret_access_key" => "{{secret.AWS_SECRET_ACCESS_KEY}}", "proxy_user_id" => "0192…", "max_messages" => 5}
A queue is consumed by a source trigger (Pipelines.Trigger, mode
message) whose source is this plugin's (source/0, Sqs.Source): the
proxy polls the queue, runs the pipeline once per message and deletes or
releases each one by how its run ended. A receive step in a pipeline a
continuous trigger runs, with a For each that deletes each message
(${input.item.receipt_handle}), does the same by hand.
The calls
Every call is a POST to the queue URL's origin with the queue URL in
its JSON body (AmazonSQS.<Action> in X-Amz-Target), signed with AWS
Signature Version 4 (Sqs.SigV4) for the service sqs in region
(taken from an AWS queue URL's host when left out). It goes to the
forward side as the proxy user proxy_user_id names
(Plugin.Provisional.Outbound), as a Request step's does, and is
recorded as an exchange of its own under the step's, its
Authorization redacted.
access_key_id is a plain template, so a tenant variable fills it;
secret_access_key is one tenant secret reference,
{{secret.AWS_SECRET_ACCESS_KEY}}, revealed in-process to sign the call
(Plugin.Secret.reveal/3) and never sent. Both and region may be set
by a Configuration step (configurable). queue_url, the receipt
handle, the FIFO ids and the attributes' values are plain templates:
each goes into a message the queue keeps and hands to its consumers.
Results
A status outside 2xx fails http_status, with the status, SQS's error
code and its message; an immediate delete SQS refuses for a message
fails sqs_failure; an answer that is not the JSON it should be fails
invalid_response. A failed call keeps the outbound call's type
(connection, timeout, tls, …).
A message is %{"message_id", "receipt_handle", "body", "attributes", "system_attributes", "receive_count"}, plus "json" when its body
parses as a JSON object or array.
In the preview
The step reaches outside (side_effect?/0): a preview sends nothing,
reveals no secret and says what it would call, with the call's
fingerprint; a played one runs for real and returns its record. In a
request phase that runs provisionally it waits for the deciding pass.
Summary
Functions
A receive step's defaults, by key.
The longest access key id a step or a source takes, in bytes.
The settings keys operation takes beside the common ones.
The outputs a step of operation produces, a subset of outputs/0: a
To row of another operation's output would write nothing, so init/1
refuses it, and the editor offers only these. An unknown operation has
all of them.
The operations a step does.
The inclusive range of a number setting.
The queue as a message source, for a source trigger (Sqs.Source).
Functions
A receive step's defaults, by key.
@spec max_access_key_id() :: pos_integer()
The longest access key id a step or a source takes, in bytes.
The settings keys operation takes beside the common ones.
@spec operation_outputs(String.t() | nil) :: [Alternera.Plugin.output()]
The outputs a step of operation produces, a subset of outputs/0: a
To row of another operation's output would write nothing, so init/1
refuses it, and the editor offers only these. An unknown operation has
all of them.
@spec operations() :: [String.t()]
The operations a step does.
The inclusive range of a number setting.
@spec source() :: module()
The queue as a message source, for a source trigger (Sqs.Source).