publishFlow
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
the Amazon Resource Name (ARN) of the SNS topic to publish the messages to.
The input Flow of PublishMessageRequests to be published.
The degree of concurrency to use for publishing messages (default is 1).
The GroupStrategy to use for grouping the messages (default is TimeWindow with 10 items and 250 milliseconds).
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
the Amazon Resource Name (ARN) of the SNS topic to publish the messages to.
The degree of concurrency to use for publishing messages (default is 1).
The GroupStrategy to use for grouping the messages (default is TimeWindow with 10 items and 250 milliseconds).
The builder that maps T to PublishRequest