receiveMessagesAsFlow

inline fun <Error class: unknown class>.receiveMessagesAsFlow(concurrency: ConcurrencyStrategy = ConcurrencyStrategy.disabled, stopOnEmptyList: Boolean = false, crossinline builder: suspend <Error class: unknown class>.() -> Unit): Flow<<Error class: unknown class>>

Continuously receives messages from an Amazon Simple Queue Service (SQS) queue using the provided SqsClient. The received messages are returned as a Flow of Message objects.

Return

A Flow of Message objects representing the messages received from the SQS queue.

Example usage:

val sqsClient = SqsClient {  }

sqsClient
.receiveMessagesAsFlow {
// This builder function is evaluated only once.
queueUrl = sqsClient.getQueueUrl { queueName = "myqueue" }.queueUrl
maxNumberOfMessages = 10
waitTimeSeconds = 20
}
.collect { message -> println("Received message: ${message.body}") }

Parameters

concurrency

The ConcurrencyStrategy to control the number of concurrent polling operations allowed. Defaults to a static strategy with concurrency of 1.

stopOnEmptyList

If true, the flow will stop when an empty list of messages is received. Defaults to false.

builder

A lambda with receiver for configuring the ReceiveMessageRequest.Builder for the underlying receive operation.