Java实现pubsub_pubsub输出以触发批处理管道

我制作了java管道,其中一个管道是从主题订阅者读取消息,如果特别喜欢“开始”字符串,则在同一程序中执行另一个管道,读取csv文件,在数据存储区中查找,加密数据并写入csv输出 .

在这个过程中,从任何条件,我都无法将pubsub管道输出传递给批处理管道的起点 .

=======================这个程序正在终止而没有运行 . 虽然没有错误......

如果我删除检查pubsub管道输出的if条件,即低于1,则数据流显示2个管道,一个用于pubsub,另一个用于文件处理 . 即使没有给pub子主题发送任何消息,文件处理管道也会运行,并且在给另一个时没有任何反应...简而言之,只有在完成pubsub管道之后才能触发批处理管道 . 请帮忙 .

代码片段如下:

PCollection pubsubPipeline =

p.apply(PubsubIO.readStrings().fromTopic(myTpoic))

.apply("window",

Window.into(SlidingWindows//

.of(Duration.standardSeconds(30))//

.every(Duration.standardSeconds(30)))) //

.apply("WordsPerLine", ParDo.of(new DoFn() {

@ProcessElement

public void processElement(ProcessContext c) throws

Exception {

String s = c.element();

final String start = "Start";

if (start.equals(s)) {

c.output(s.toString());

} else {

LOG.info("Start not found");

return;

// throw new Exception();

}

}

}));

String start = "Start";

// String stsubs = pubsubPipeline.toString();

if (start.equals(pubSubPipeline))

{

LOG.info("Come in if condition");

LOG.info("Reading input file");

PCollection lines = p.apply("Read

File",TextIO.read().from(input));

LOG.info("Lookup in the datastore");

PCollection>> entitySet =

lines.apply("Query", ParDo.of(new DoFn

List>>() {

@ProcessElement

::

:

:

PCollection output = userSet.apply("Print Entity",

ParDo.of(new DoFn() {

@ProcessElement

public void processElement(ProcessContext c) throws Exception {

User user = c.element();

if (user != null && user.getEmail() != null &&

user.getEmail().equals(user.getEncryptedEmail())) {

user.setEncryptedEmail(null);

}

c.output(user.toString());

}

}));

output.apply(TextIO.write().withHeader("User Id,Email,Encrypted Email").to(outputPrefix).withSuffix(".csv").withoutSharding());

p.run().waitUntilFinish();

}

else

LOG.info("comes in else condition");

return;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值