[英]How to get the Pipeline status in Dataflow with multiple ParDo using Apache Bean Java
Pipeline contain multiple ParDo functions(Refer below code).Need to send the Failed message to pubsub topic when Dataflow pipeline ParDo function failed.管道包含多个 ParDo 函数(参考下面的代码)。需要在数据流管道 ParDo function 失败时将失败消息发送到 pubsub 主题。 Tried with PipelineResults we are not able to get the status.尝试使用 PipelineResults 我们无法获得状态。 Any centralized logic to implement status when dataflow pipeline failed?当数据流管道失败时,是否有任何集中逻辑来实现状态? Kindly suggest me the idea to resolve the issue.请建议我解决问题的想法。
public class PubMessage {
public static final Logger LOG = LoggerFactory.getLogger(PubMessage.class.getName());
public static void main(String[] args) {
PipelineOption options = PipelineOptionsFactory.fromArgs(args).as(PipelineOption.class);
Pipeline pipeline = Pipeline.create(options);
PCollection<String> input = pipeline.apply("Read Dummy File", new ReadDummyFile(options.getDummyFilepath()));
Publish Pubsub Message to Topic
input.apply("Pardo", ParDo.of(new msg(options.getPath()))).apply("Publish Pubsub Message",PubsubIO.writeMessages().to(options.getTopic()));
// Publish second message to Topic
String print_topic = options.getTopic();
input.apply("Pardo", ParDo.of(new msgSecond("Read text").apply("Publish Pubsub Message",PubsubIO.writeMessages().to(options.getTopic()));
PipelineResult p = pipeline.run();
if (PipelineResult.State.FAILED.equals(p.waitUntilFinish())) {
throw new RuntimeException("Pipeline failed for unknown reason");
// send pubsub msg
}
msg消息
public class msg extends DoFn<String, PubsubMessage> {
@ProcessElement
public void processElement(ProcessContext c) {
//get the value sending msg to topic
c.output(message);
}
}
msgSecond
public class msgSecondextends DoFn<String, PubsubMessage> {
@ProcessElement
public void processElement(ProcessContext c) {
//get the value sending msg to topic
c.output(message);
}
}
A streaming pipeline will keep trying rather than completing in a failed state. You could publish the message from within the DoFn itself.流式传输管道将继续尝试而不是在失败的 state 中完成。您可以从 DoFn 本身内部发布消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.