[
https://issues.apache.org/jira/browse/BEAM-13653?focusedWorklogId=712982&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-712982
]
ASF GitHub Bot logged work on BEAM-13653:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 21/Jan/22 17:04
Start Date: 21/Jan/22 17:04
Worklog Time Spent: 10m
Work Description: mosche commented on a change in pull request #16503:
URL: https://github.com/apache/beam/pull/16503#discussion_r789843552
##########
File path:
sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/sns/SnsIO.java
##########
@@ -418,8 +420,14 @@ public void setup() throws Exception {
@ProcessElement
public void processElement(ProcessContext context) throws Exception {
- PublishRequest request =
- (PublishRequest)
spec.getPublishRequestFn().apply(context.element());
+ PublishRequest.Builder reqBuilder =
Review comment:
It's actually not any different from before ... only if one uses the
deprecated old interface there's an additional roundtrip converting a
`PublishRequest` to `PublishRequest.Builder` to set the `topic` and back to
`PublishRequest`.
Previously `publishRequestFn` as `T => PublishRequest` was also using a
`PublishRequest.Builder` per input element. But the request had to be build
immediately. E.g.
```java
PublishRequest.builder().topicArn("topicArn").message(m).build()
```
It would be possible to use `(T, PublishRequest.Builder) => PublishRequest`
instead and reuse the same builder. But that comes with a rather high risk of
leaking state between input elements as soon as fields are set conditionally by
users. And the AWS SDK doesn't allow clearing a builder, so each field has to
be reset manually with the risk of missing newly added fields.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 712982)
Time Spent: 0.5h (was: 20m)
> Improved handling of topicArn in SnsIO.write
> ---------------------------------------------
>
> Key: BEAM-13653
> URL: https://issues.apache.org/jira/browse/BEAM-13653
> Project: Beam
> Issue Type: Improvement
> Components: io-java-aws
> Reporter: Moritz Mack
> Assignee: Moritz Mack
> Priority: P2
> Labels: aws, aws-sdk-v2
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Usage of SnsIO.write is rather unintuitive at the moment.
> topicArn is a required configuration and during expansion the existence of
> the topic is validated.
> However, the user also has to provide a function to build an SNS publish
> request. The topicArn for that publish request has to be set as well, but can
> be different from the one configured and validated in the writer.
> This is confusing and makes any validation pointless.
> Also, when validating the SNS client instance is not closed.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)