ExAws.SQS (ExAws.SQS v3.4.0) View Source

Operations on AWS SQS.

Link to this section Summary

Functions

Adds a permission with the provided label to the Queue for a specific action for a specific account.

Extends the read lock timeout for the specified message from the specified queue to the specified value.

Extends the read lock timeout for a batch of 1..10 messages.

Delete a message from a SQS Queue

Deletes a list of messages from a SQS Queue in a single request

Delete a queue

Retrieves the dead letter source queues for a given SQS Queue

List tags of a SQS Queue.

Retrieves a list of all the SQS Queues

Purge all messages in a SQS Queue

Read messages from a SQS Queue

Removes permission with the given label from the Queue

Send a message to a SQS Queue

Send up to 10 messages to a SQS Queue in a single request.

Set attributes of a SQS Queue.

Apply tags to a SQS Queue.

Remove tags from a SQS Queue.

Link to this section Types

Link to this type

delete_message_batch_item()

View Source

Specs

delete_message_batch_item() :: %{id: binary(), receipt_handle: binary()}
Link to this type

message_visibility_batch_item()

View Source

Specs

message_visibility_batch_item() :: %{
  id: binary(),
  receipt_handle: binary(),
  visibility_timeout: visibility_timeout()
}

Specs

queue_attributes() :: [
  policy: binary(),
  visibility_timeout: visibility_timeout(),
  maximum_message_size: 1024..262_144,
  message_retention_period: 60..1_209_600,
  approximate_number_of_messages: binary(),
  approximate_number_of_messages_not_visible: binary(),
  created_timestamp: binary(),
  last_modified_timestamp: binary(),
  queue_arn: binary(),
  approximate_number_of_messages_delayed: binary(),
  delay_seconds: 0..900,
  receive_message_wait_time_seconds: 0..20,
  redrive_policy: binary(),
  fifo_queue: boolean(),
  content_based_deduplication: boolean(),
  kms_master_key_id: binary(),
  kms_data_key_reuse_period_seconds: 60..86400
]
Link to this type

receive_message_opts()

View Source

Specs

receive_message_opts() :: [
  attribute_names: :all | [sqs_message_attribute_name(), ...],
  message_attribute_names: :all | [String.Chars.t(), ...],
  max_number_of_messages: 1..10,
  visibility_timeout: 0..43200,
  wait_time_seconds: 0..20,
  receive_request_attempt_id: String.t()
]

Specs

sqs_acl() :: %{required(binary()) => :all | [sqs_permission(), ...]}

Specs

sqs_batch_message() ::
  binary()
  | [
      id: binary(),
      message_body: binary(),
      delay_seconds: 0..900,
      message_attributes:
        sqs_message_attribute() | [sqs_message_attribute(), ...],
      message_deduplication_id: binary(),
      message_group_id: binary()
    ]
Link to this type

sqs_message_attribute()

View Source

Specs

sqs_message_attribute() :: %{
  name: binary(),
  data_type: :string | :binary | :number,
  custom_type: binary() | none(),
  value: binary() | number()
}
Link to this type

sqs_message_attribute_name()

View Source

Specs

sqs_message_attribute_name() ::
  :sender_id
  | :sent_timestamp
  | :approximate_receive_count
  | :approximate_first_receive_timestamp
  | :sequence_number
  | :message_deduplication_id
  | :message_group_id
  | :aws_trace_header

Specs

sqs_message_opts() :: [
  delay_seconds: 0..900,
  message_attributes: sqs_message_attribute() | [sqs_message_attribute(), ...],
  message_deduplication_id: binary(),
  message_group_id: binary()
]

Specs

sqs_permission() ::
  :send_message
  | :receive_message
  | :delete_message
  | :change_message_visibility
  | :get_queue_attributes
Link to this type

sqs_queue_attribute_name()

View Source

Specs

sqs_queue_attribute_name() ::
  :policy
  | :visibility_timeout
  | :maximum_message_size
  | :message_retention_period
  | :approximate_number_of_messages
  | :approximate_number_of_messages_not_visible
  | :created_timestamp
  | :last_modified_timestamp
  | :queue_arn
  | :approximate_number_of_messages_delayed
  | :delay_seconds
  | :receive_message_wait_time_seconds
  | :redrive_policy
  | :fifo_queue
  | :content_based_deduplication

Specs

visibility_timeout() :: 0..43200

Link to this section Functions

Link to this function

add_permission(queue_url, label, permissions \\ %{})

View Source

Specs

add_permission(
  queue_url :: binary(),
  label :: binary(),
  permissions :: sqs_acl()
) ::
  ExAws.Operation.Query.t()

Adds a permission with the provided label to the Queue for a specific action for a specific account.

AWS API Docs

Link to this function

change_message_visibility(queue_url, receipt_handle, visibility_timeout)

View Source

Specs

change_message_visibility(
  queue_url :: binary(),
  receipt_handle :: binary(),
  visibility_timeout :: visibility_timeout()
) :: ExAws.Operation.Query.t()

Extends the read lock timeout for the specified message from the specified queue to the specified value.

AWS API Docs

Link to this function

change_message_visibility_batch(queue_url, messages)

View Source

Specs

change_message_visibility_batch(
  queue_url :: binary(),
  opts :: [message_visibility_batch_item(), ...]
) :: ExAws.Operation.Query.t()

Extends the read lock timeout for a batch of 1..10 messages.

AWS API Docs

Link to this function

create_queue(queue_name, attributes \\ [], tags \\ %{})

View Source

Create queue.

AWS API Docs

Attributes

  • :delay_seconds - The length of time, in seconds, for which the delivery of all messages in the queue is delayed. Valid values: An integer from 0 to 900 seconds (15 minutes). Default: 0.

  • :maximum_message_size - The limit of how many bytes a message can contain before Amazon SQS rejects it. Valid values: An integer from 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB). Default: 262,144 (256 KiB).

  • :message_retention_period - The length of time, in seconds, for which Amazon SQS retains a message. Valid values: An integer from 60 seconds (1 minute) to 1,209,600 seconds (14 days). Default: 345,600 (4 days).

  • :policy - The queue's policy. A valid AWS policy. For more information about policy structure, see Overview of AWS IAM Policies in the Amazon IAM User Guide.

  • :receive_message_wait_time_seconds - The length of time, in seconds, for which a ReceiveMessage action waits for a message to arrive. Valid values: An integer from 0 to 20 (seconds). Default: 0.

  • :redrive_policy - The string that includes the parameters for the dead-letter queue functionality of the source queue as a JSON object. For more information about the redrive policy and dead-letter queues, see Using Amazon SQS Dead-Letter Queues in the Amazon Simple Queue Service Developer Guide.

    • deadLetterTargetArn – The Amazon Resource Name (ARN) of the dead-letter queue to which Amazon SQS moves messages after the value of maxReceiveCount is exceeded.

    • maxReceiveCount – The number of times a message is delivered to the source queue before being moved to the dead-letter queue. When the ReceiveCount for a message exceeds the maxReceiveCount for a queue, Amazon SQS moves the message to the dead-letter-queue. Note The dead-letter queue of a FIFO queue must also be a FIFO queue. Similarly, the dead-letter queue of a standard queue must also be a standard queue.

  • :visibility_timeout - The visibility timeout for the queue, in seconds. Valid values: An integer from 0 to 43,200 (12 hours). Default: 30. For more information about the visibility timeout, see Visibility Timeout in the Amazon Simple Queue Service Developer Guide.

  • :fifo_queue - Designates a queue as FIFO. Valid values: true, false. If you don't specify the FifoQueue attribute, Amazon SQS creates a standard queue. You can provide this attribute only during queue creation. You can't change it for an existing queue. When you set this attribute, you must also provide the MessageGroupId for your messages explicitly. For more information, see FIFO Queue Logic in the Amazon Simple Queue Service Developer Guide.

  • :content_based_deduplication - Enables content-based deduplication. Valid values: true, false. For more information, see Exactly-Once Processing in the Amazon Simple Queue Service Developer Guide.

  • :kms_master_key_id - The ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. For more information, see Key Terms. While the alias of the AWS-managed CMK for Amazon SQS is always alias/aws/sqs, the alias of a custom CMK can, for example, be alias/MyAlias . For more examples, see KeyId in the AWS Key Management Service API Reference.

  • :kms_data_key_reuse_period_seconds - The length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). Default: 300 (5 minutes). A shorter time period provides better security but results in more calls to KMS which might incur charges after Free Tier. For more information, see How Does the Data Key Reuse Period Work?.

Link to this function

delete_message(queue_url, receipt_handle)

View Source

Specs

delete_message(queue_url :: binary(), receipt_handle :: binary()) ::
  ExAws.Operation.Query.t()

Delete a message from a SQS Queue

AWS API Docs

Link to this function

delete_message_batch(queue_url, messages)

View Source

Specs

delete_message_batch(
  queue_url :: binary(),
  message_receipts :: [delete_message_batch_item(), ...]
) :: ExAws.Operation.Query.t()

Deletes a list of messages from a SQS Queue in a single request

AWS API Docs

Specs

delete_queue(queue_url :: binary()) :: ExAws.Operation.Query.t()

Delete a queue

AWS API Docs

Link to this function

get_queue_attributes(queue_url, attributes \\ :all)

View Source

Specs

get_queue_attributes(
  queue_url :: binary(),
  attribute_names :: :all | [sqs_queue_attribute_name(), ...]
) :: ExAws.Operation.Query.t()

Gets attributes of a SQS Queue

AWS API Docs

Link to this function

get_queue_url(queue_name, opts \\ [])

View Source

Specs

get_queue_url(
  queue_name :: binary(),
  opts :: [{:queue_owner_aws_account_id, binary()}]
) ::
  ExAws.Operation.Query.t()

Get queue URL

AWS API Docs

Options

  • :queue_owner_aws_account_id - The AWS account ID of the account that created the queue.
Link to this function

list_dead_letter_source_queues(queue_url)

View Source

Specs

list_dead_letter_source_queues(queue_url :: binary()) ::
  ExAws.Operation.Query.t()

Retrieves the dead letter source queues for a given SQS Queue

AWS API Docs

Link to this function

list_queue_tags(queue_url)

View Source

Specs

list_queue_tags(queue_url :: binary()) :: ExAws.Operation.Query.t()

List tags of a SQS Queue.

AWS API Docs

Specs

list_queues(opts :: [{:queue_name_prefix, binary()}]) ::
  ExAws.Operation.Query.t()

Retrieves a list of all the SQS Queues

AWS API Docs

Options

  • :queue_name_prefix - A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned. Queue URLs and names are case-sensitive.

Specs

purge_queue(queue_url :: binary()) :: ExAws.Operation.Query.t()

Purge all messages in a SQS Queue

AWS API Docs

Link to this function

receive_message(queue_url, opts \\ [])

View Source

Specs

receive_message(queue_url :: binary(), opts :: receive_message_opts()) ::
  ExAws.Operation.Query.t()

Read messages from a SQS Queue

AWS API Docs

Options

  • :attribute_names - :all or a list of AttributeNames to include in the response. Valid attributes are: [:sender_id, :sent_timestamp, :approximate_receive_count, :approximate_first_receive_timestamp, :sequence_number, :message_deduplication_id, :message_group_id, :aws_trace_header]

  • :message_attribute_names - List of message attributes to include.

    • The name can contain alphanumeric characters and the underscore (_), hyphen (-), and period (.).
    • The name is case-sensitive and must be unique among all attribute names for the message.
    • The name must not start with AWS-reserved prefixes such as AWS. or Amazon. (or any casing variants).
    • The name must not start or end with a period (.), and it should not have periods in succession (..).
    • The name can be up to 256 characters long. When using ReceiveMessage, you can send a list of attribute names to receive, or you can return all of the attributes by specifying All or . in your request. You can also use all message attributes starting with a prefix, for example bar..
  • :max_number_of_messages - The maximum number of messages to return. Amazon SQS never returns more messages than this value (however, fewer messages might be returned). Valid values: 1 to 10. Default: 1.

  • :visibility_timeout - The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

  • :wait_time_seconds - The duration (in seconds) for which the call waits for a message to arrive in the queue before returning. If a message is available, the call returns sooner than WaitTimeSeconds. If no messages are available and the wait time expires, the call returns successfully with an empty list of messages.

  • :receive_request_attempt_id - This parameter applies only to FIFO (first-in-first-out) queues.

    The token used for deduplication of ReceiveMessage calls. If a networking issue occurs after a ReceiveMessage action, and instead of a response you receive a generic error, it is possible to retry the same action with an identical ReceiveRequestAttemptId to retrieve the same set of messages, even if their visibility timeout has not yet expired.

Link to this function

remove_permission(queue_url, label)

View Source

Specs

remove_permission(queue_url :: binary(), label :: binary()) ::
  ExAws.Operation.Query.t()

Removes permission with the given label from the Queue

AWS API Docs

Link to this function

send_message(queue_url, message, opts \\ [])

View Source

Specs

send_message(
  queue_url :: binary(),
  message_body :: binary(),
  opts :: sqs_message_opts()
) ::
  ExAws.Operation.Query.t()

Send a message to a SQS Queue

AWS API Docs

Options

  • :delay_seconds - The length of time, in seconds, for which to delay a specific message. Valid values: 0 to 900. Maximum: 15 minutes. Messages with a positive DelaySeconds value become available for processing after the delay period is finished. If you don't specify a value, the default value for the queue applies.

  • :message_attributes - Each message attribute consists of a Name, Type, and Value. For more information, see Amazon SQS Message Attributes in the Amazon Simple Queue Service Developer Guide.

  • :message_deduplication_id - This parameter applies only to FIFO (first-in-first-out) queues.

  • :message_group_id - This parameter applies only to FIFO (first-in-first-out) queues.

Link to this function

send_message_batch(queue_url, messages)

View Source

Specs

send_message_batch(
  queue_url :: binary(),
  messages :: [sqs_batch_message(), ...]
) ::
  ExAws.Operation.Query.t()

Send up to 10 messages to a SQS Queue in a single request.

AWS API Docs

Link to this function

set_queue_attributes(queue_url, attributes \\ [])

View Source

Specs

set_queue_attributes(queue_url :: binary(), attributes :: queue_attributes()) ::
  ExAws.Operation.Query.t()

Set attributes of a SQS Queue.

AWS API Docs

Link to this function

tag_queue(queue_url, tags)

View Source

Specs

tag_queue(queue_url :: binary(), tags :: map()) :: ExAws.Operation.Query.t()

Apply tags to a SQS Queue.

AWS API Docs

Link to this function

untag_queue(queue_url, tag_keys)

View Source

Specs

untag_queue(queue_url :: binary(), tag_keys :: list()) ::
  ExAws.Operation.Query.t()

Remove tags from a SQS Queue.

AWS API Docs