publishFlow

fun <Error class: unknown class>.publishFlow(topicArn: String, upstream: Flow<<Error class: unknown class>>, concurrency: Int = 1, groupStrategy: GroupStrategy = GroupStrategy.TimeWindow(10, 250.milliseconds)): Flow<<Error class: unknown class>>

The publishFlow function is used to publish messages concurrently to an Amazon Simple Notification Service (SNS) topic using a SnsClient.

It takes an input Flow of PublishRequest and publishes the messages concurrently, respecting the specified groupStrategy.

The groupStrategy parameter defines how the messages should be grouped. Using a time window, for instance, the messages are going to be grouped either when the maximum number of items is reached, or when the time duration has elapsed, whichever comes first. This can help balance between processing latency and the granularity of data aggregation, leading to more efficient processing by potentially reducing the number of requests to AWS.

Return

A Flow of PublishResponses for the published messages.

Example usage:

val snsClient: SnsClient = ...
val messages: Flow<PublishMessageRequest> = ...
val topicArn = "arn:aws:sns:us-east-1:123456789012:MyTopic"

val responses: Flow<PublishResponse> = snsClient.publishFlow(topicArn, messages)

responses.collect { response -> println(response) }

Parameters

topicArn

the Amazon Resource Name (ARN) of the SNS topic to publish the messages to.

upstream

The input Flow of PublishMessageRequests to be published.

concurrency

The degree of concurrency to use for publishing messages (default is 1).

groupStrategy

The GroupStrategy to use for grouping the messages (default is TimeWindow with 10 items and 250 milliseconds).


fun <T> Flow<T>.publishFlow(topicArn: String, concurrency: Int = 1, groupStrategy: GroupStrategy = GroupStrategy.TimeWindow(10, 250.milliseconds), builder: <Error class: unknown class>.(T) -> Unit): Flow<<Error class: unknown class>>

The publishFlow function is used to publish messages concurrently to an Amazon Simple Notification Service (SNS) topic using a SnsClient.

It takes an input Flow of T, maps to PublishRequest and publishes the messages concurrently, respecting the specified groupStrategy.

The groupStrategy parameter defines how the messages should be grouped. Using a time window, for instance, the messages are going to be grouped either when the maximum number of items is reached, or when the time duration has elapsed, whichever comes first. This can help balance between processing latency and the granularity of data aggregation, leading to more efficient processing by potentially reducing the number of requests to AWS.

Return

A Flow of PublishResponses for the published messages.

Example usage:

val snsClient: SnsClient = ...
val numbers: Flow<Int> = (1..20).asFlow()
val topicArn = "arn:aws:sns:us-east-1:123456789012:MyTopic"

val responses: Flow<PublishMessageResponse> = with(snsClient) {
numbers.publishFlow(topicArn) { number ->
message = "$number"
}
}

responses.collect { response -> println(response) }

Parameters

topicArn

the Amazon Resource Name (ARN) of the SNS topic to publish the messages to.

concurrency

The degree of concurrency to use for publishing messages (default is 1).

groupStrategy

The GroupStrategy to use for grouping the messages (default is TimeWindow with 10 items and 250 milliseconds).

builder

The builder that maps T to PublishRequest