Class SnsIO
- java.lang.Object
-
- org.apache.beam.sdk.io.aws2.sns.SnsIO
-
@Experimental(SOURCE_SINK) public final class SnsIO extends java.lang.ObjectIO to send notifications via SNS.Writing to SNS
Example usage:
PCollection<String> data = ...; data.apply(SnsIO.<String>write() .withTopicArn("topicArn") .withPublishRequestBuilder(msg -> PublishRequest.builder().message(msg)));At a minimum you have to provide:
- SNS topic ARN you're going to publish to (optional, but required for most use cases)
- Request builder function to create SNS publish requests from your input
By default, the output
PublishResponsecontains only the SNS messageId, all other fields are null. If you need to include the fullSdkHttpResponseandAwsResponseMetadata, you can callSnsIO.Write.withFullPublishResponse(). If you need the HTTP status code only but no headers, you can useSnsIO.Write.withFullPublishResponseWithoutHeaders().Configuration of AWS clients
AWS clients for all AWS IOs can be configured using
AwsOptions, e.g.--awsRegion=us-west-1.AwsOptionscontain reasonable defaults based on default providers forRegionandAwsCredentialsProvider.If you require more advanced configuration, you may change the
ClientBuilderFactoryusingAwsOptions.setClientBuilderFactory(Class).Configuration for a specific IO can be overwritten using
withClientConfiguration(), which also allows to configure the retry behavior for the respective IO.Retries
Retries for failed requests can be configured using
ClientConfiguration.Builder.retry(Consumer)and are handled by the AWS SDK unless there's a partial success (batch requests). The SDK uses a backoff strategy with equal jitter for computing the delay before the next retry.Note: Once retries are exhausted the error is surfaced to the runner which may then opt to retry the current partition in entirety or abort if the max number of retries of the runner is reached.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnsIO.RetryConfigurationDeprecated.UseRetryConfigurationinstead to delegate retries to the AWS SDK.protected static classSnsIO.SnsWriteExceptionException class for SNS write exceptions.static classSnsIO.Write<T>Implementation ofwrite().static classSnsIO.WriteAsync<T>Deprecated.Please usewrite()to avoid the risk of data loss.
-
Constructor Summary
Constructors Constructor Description SnsIO()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> SnsIO.Write<T>write()static <T> SnsIO.WriteAsync<T>writeAsync()Deprecated.Please usewrite()to avoid the risk of data loss.
-
-
-
Method Detail
-
write
public static <T> SnsIO.Write<T> write()
-
writeAsync
@Deprecated public static <T> SnsIO.WriteAsync<T> writeAsync()
Deprecated.Please usewrite()to avoid the risk of data loss.- See Also:
- Issue #21366, BEAM-13203
-
-