-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements (at-least-once delivery, batch deletions, message visibility extensions) #770
Conversation
… to focus on processing messages and once successful, deleting the messages from the queue. In addition, if processing takes long, automatic message extension requests are sent out to SQS so other consumers won't see the message until processing finishes - Improve SqsStream so deletes are batched reducing API calls - Implement batch deletes - Implement message visibility extension (batch/single)
I've done testing against ElasticMQ, next up - I'm going to run some tests against AWS SQS and ensure everything works as expected (especially around the message visibility extension timeouts and batch deletes) |
…arantees (especially in FIFO)
AWS SQS testing (Note: account removed): val producerLayer: RLayer[Sqs, Producer[String]] =
ZLayer.scoped(
Producer.make(
queueUrl = "https://sqs.us-east-1.amazonaws.com/000/calqstandard",
serializer = Serializer.serializeString,
settings = ProducerSettings(parallelism = 1)
)
)
val producerExample =
ZIO.serviceWithZIO[Producer[String]] { producer =>
producer.produceBatch(
(1 to 1_000).map(i => ProducerEvent(s"Message $i"))
)
}
val consumerExample =
SqsStream.consumeChunkAtLeastOnce(
queueUrl = "https://sqs.us-east-1.amazonaws.com/000/calqstandard",
settings = SqsStreamSettings(
maxNumberOfMessages = 10,
visibilityTimeout = Some(5),
waitTimeSeconds = Some(20)
),
extensionSettings = SqsMessageLifetimeExtensionSettings.default,
consumerParallelism = 2
) { messages =>
ZIO.debug(messages.map(_.body.getOrElse(""))) *> ZIO.sleep(14.seconds)
} Notice that I'm purposely taking 14 seconds when the visibility timeout is 5 seconds so that the automatic extension process is renewing the lease on the message and keeping it invisible from other queue consumers. Also did some checks to ensure that messages that are pulled from the queue won't reappear back on the queue due to the extension process that takes place in the background to minimize the change of duplicate processing. |
…semantics as well
… deletion retries are exhausted
f012e24
to
c36c62b
Compare
Co-authored-by: ZIO Assistant <zio-assistant[bot]@users.noreply.github.com>
Changes
consumeChunkAtLeastOnce
) that allows users to focus on processing messages and once successful, deleting the messages from the queue.consumeChunk
APIautoDelete=true
)consumeChunkAtLeastOnce
that ensure failed processing causes re-delivery and the automatic extension process is functioning correctlydeleteMessageBatchSink
which can be used withSqsStream
withautoDelete=false
to provide at-least-once delivery semantics so users can process their message and then delete it.Addresses #587 and #259 including taking care of retries during batched deletes
Note: There are breaking changes to adhere to the AWS defaults in SqsSettings as well as removing an unneeded type parameter in
Producer.make