← ZIO SQS docs

SqsStream

zio.sqs.SqsStream
object SqsStream

Reads messages from an SQS queue as a stream, and deletes, extends or processes them.

Attributes

Source
SqsStream.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
SqsStream.type

Members list

Value members

Concrete methods

def apply(queueUrl: String, settings: SqsStreamSettings = ...): ZStream[Sqs, Throwable, ReadOnly]

Creates a consumer stream that pulls messages from the SQS queue. The stream repeatedly calls ReceiveMessage and emits each batch it receives, one message at a time. Note that if you set autoDelete to true, the message will be deleted from SQS before you can process the message (so if you fail to process the message, it will be deleted).

Creates a consumer stream that pulls messages from the SQS queue. The stream repeatedly calls ReceiveMessage and emits each batch it receives, one message at a time. Note that if you set autoDelete to true, the message will be deleted from SQS before you can process the message (so if you fail to process the message, it will be deleted).

Value parameters

queueUrl

is the SQS queue URL (example: https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue)

settings

are the settings for reading messages from the queue

Attributes

Returns

a stream of messages from the queue

Source
SqsStream.scala
def consumeChunkAtLeastOnce(queueUrl: String, settings: SqsStreamSettings, extensionSettings: SqsMessageLifetimeExtensionSettings, consumerParallelism: Int = ...)(process: Chunk[ReadOnly] => Task[Unit]): RIO[Sqs, Unit]

Consumes a batch of messages from the queue and deletes them after successful processing so users can focus on processing messages. This will ignore autoDelete since messages are deleted only after successful processing. This will also respect the stopWhenQueueEmpty setting. This will delete messages from the queue only after they have been successfully processed (process function).

Consumes a batch of messages from the queue and deletes them after successful processing so users can focus on processing messages. This will ignore autoDelete since messages are deleted only after successful processing. This will also respect the stopWhenQueueEmpty setting. This will delete messages from the queue only after they have been successfully processed (process function).

Value parameters

consumerParallelism

is the number of parallel consumers to run (default: 1)

extensionSettings

are the settings for the message lifetime extension

process

is the function to process the messages

queueUrl

is the SQS queue URL (example: https://sqs.us-east-1.amazonaws.com/123456789012/MyQueue)

settings

are the settings for reading messages from the queue

Attributes

Source
SqsStream.scala
def deleteMessage(queueUrl: String, msg: ReadOnly): RIO[Sqs, Unit]

Deletes one message from the queue, using the message's receipt handle. If the message has no receipt handle, the request uses an empty string as the receipt handle.

Deletes one message from the queue, using the message's receipt handle. If the message has no receipt handle, the request uses an empty string as the receipt handle.

Value parameters

msg

is the message to delete

queueUrl

is the SQS queue URL

Attributes

Source
SqsStream.scala
def deleteMessageBatch(queueUrl: String, msgs: Chunk[ReadOnly], maximumRetries: Int = ...): RIO[Sqs, Chunk[ReadOnly]]

Deletes a batch of messages from the queue. It retries the entries that fail, and finds them again by their position in msgs, which it uses as the batch entry ID. It chunks up the messages into batches of 10 before deleting them to avoid hitting the SQS limit of 10 messages per deleteMessageBatch call. Each batch retries its failed entries up to maximumRetries times. If entries of a batch still fail after the last retry, the effect fails with a RuntimeException whose message is Failed to delete messages after retrying. For each batch of 10, the returned chunk holds only the messages that succeeded in that batch's last attempt. Messages that succeeded in an earlier attempt of the same batch are not included.

Deletes a batch of messages from the queue. It retries the entries that fail, and finds them again by their position in msgs, which it uses as the batch entry ID. It chunks up the messages into batches of 10 before deleting them to avoid hitting the SQS limit of 10 messages per deleteMessageBatch call. Each batch retries its failed entries up to maximumRetries times. If entries of a batch still fail after the last retry, the effect fails with a RuntimeException whose message is Failed to delete messages after retrying. For each batch of 10, the returned chunk holds only the messages that succeeded in that batch's last attempt. Messages that succeeded in an earlier attempt of the same batch are not included.

Value parameters

maximumRetries

is the number of retries for the entries that fail, per batch of 10

msgs

are the messages to delete

queueUrl

is the SQS queue URL

Attributes

Returns

for each batch of 10, the messages that succeeded in that batch's last attempt

Source
SqsStream.scala
def deleteMessageBatchSink(queueUrl: String, maximumRetries: Int = ...): ZSink[Sqs, Throwable, ReadOnly, Nothing, Unit]

A sink that deletes each chunk of messages from the queue, using deleteMessageBatch. If you use SqsStream with autoDelete = false in conjunction with this sink, you will get at-least-once semantics since the messages will be deleted after they are successfully processed.

A sink that deletes each chunk of messages from the queue, using deleteMessageBatch. If you use SqsStream with autoDelete = false in conjunction with this sink, you will get at-least-once semantics since the messages will be deleted after they are successfully processed.

Value parameters

maximumRetries

is the number of retries for the entries that fail

queueUrl

is the SQS queue URL

Attributes

Returns

a sink that deletes the messages it receives

Source
SqsStream.scala
def extendMessageLifetime(queueUrl: String, message: ReadOnly, seconds: Int): RIO[Sqs, Unit]

Extends the visibility timeout of a message to the specified number of seconds. This is useful when you need to process a message and the time it takes to process it is longer than the visibility timeout. If the message has no receipt handle, the request uses an empty string as the receipt handle.

Extends the visibility timeout of a message to the specified number of seconds. This is useful when you need to process a message and the time it takes to process it is longer than the visibility timeout. If the message has no receipt handle, the request uses an empty string as the receipt handle.

Value parameters

message

is the message whose visibility timeout to change

queueUrl

is the SQS queue URL

seconds

is the new visibility timeout, in seconds

Attributes

Source
SqsStream.scala
def extendMessageLifetimeBatch(queueUrl: String, messages: Chunk[ReadOnly], seconds: Int, maximumRetries: Int = ...): RIO[Sqs, Chunk[ReadOnly]]

Sets the visibility timeout of many messages to the specified number of seconds, in batches of 10. The messages are sent in batches of 10. SQS can fail some entries of a batch. Each batch retries its failed entries up to maximumRetries times. If entries of a batch still fail after the last retry, the effect fails with a RuntimeException whose message is Failed to change message visibility after retrying. For each batch of 10, the returned chunk holds only the messages that succeeded in that batch's last attempt. Messages that succeeded in an earlier attempt of the same batch are not included.

Sets the visibility timeout of many messages to the specified number of seconds, in batches of 10. The messages are sent in batches of 10. SQS can fail some entries of a batch. Each batch retries its failed entries up to maximumRetries times. If entries of a batch still fail after the last retry, the effect fails with a RuntimeException whose message is Failed to change message visibility after retrying. For each batch of 10, the returned chunk holds only the messages that succeeded in that batch's last attempt. Messages that succeeded in an earlier attempt of the same batch are not included.

Value parameters

maximumRetries

is the number of retries for the entries that fail, per batch of 10

messages

are the messages whose visibility timeout to change

queueUrl

is the SQS queue URL

seconds

is the new visibility timeout, in seconds

Attributes

Returns

for each batch of 10, the messages that succeeded in that batch's last attempt

Source
SqsStream.scala