Naireen commented on code in PR #30372:
URL: https://github.com/apache/beam/pull/30372#discussion_r1501342511
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsub/PreparePubsubWriteDoFn.java:
##########
@@ -125,18 +140,42 @@ public void process(
@Timestamp Instant ts,
BoundedWindow window,
PaneInfo paneInfo,
- OutputReceiver<PubsubMessage> o) {
+ MultiOutputReceiver o)
+ throws Exception {
ValueInSingleWindow<InputT> valueInSingleWindow =
ValueInSingleWindow.of(element, ts, window, paneInfo);
- PubsubMessage message = formatFunction.apply(valueInSingleWindow);
+ PubsubMessage message;
+ try {
+ message = formatFunction.apply(valueInSingleWindow);
+ } catch (Exception e) {
+ badRecordRouter.route(
+ o,
+ element,
+ inputCoder,
+ e,
+ "Failed to serialize PubSub message with provided format function");
+ return;
+ }
if (topicFunction != null) {
- message =
message.withTopic(topicFunction.apply(valueInSingleWindow).asPath());
+ try {
+ message =
message.withTopic(topicFunction.apply(valueInSingleWindow).asPath());
+ } catch (Exception e) {
+ badRecordRouter.route(
+ o, element, inputCoder, e, "Failed to determine PubSub topic using
topic function");
Review Comment:
Should we just add valueInSingleWindow into the error message here so its
easier to see what went wrong?
--
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]