我具有以下数据流批处理的工作流程:
在完成管道的最后阶段,我正在发布到PubSub,并且我具有云功能来选择有关特定主题的消息并发送闲置通知。我必须添加pipeline.run().waitUntilItFinish()
才能在末尾触发PubSub通知。否则,它将发布成功处理PCollection的每个转换
我的管道具有当前的主类:
public static void main(String[] args) throws Exception {
final CustomOptions options = PipelineOptionsFactory.fromArgs(args).withValidation().as(CustomOptions.class);
final Pair<String, LocalDatastoreHelper> datastorePair = DatastoreUpdater.createUpdateDatastoreFetchParameters(options.getEnv());
final String datastoreProjectId = datastorePair.getKey();
final Pipeline pipeline = Pipeline.create(options);
DataPreparation dataPreparation = new DataPreparation(pipeline, options);
GroupAccountProcessing.groupAccountUpdate(options, dataPreparation, datastoreProjectId);
GroupAccountProcessing.groupAccountSeatsUpdate(options, dataPreparation, datastoreProjectId);
TempAccountProcessing.processTempAccount(options, dataPreparation, datastoreProjectId);
DigitalAccountProcessing.processDigital(options, dataPreparation, datastoreProjectId);
ProductAccountProcessing.processProduct(options, dataPreparation, datastoreProjectId);
try {
PipelineResult.State state = pipeline.run().waitUntilFinish();
SlackNotification.notifySlack(options.getTopic(), options.getJobName(), options.getRunMode(), state);
} catch (Exception e) {
e.printStackTrace();
LocalDatastoreHelper helper = datastorePair.getValue();
if (helper != null) {
helper.stop();
System.setProperty("DATASTORE_EMULATOR_HOST", "");
System.setProperty("DATASTORE_PROJECT_ID", "");
}
}
}
仅当我通过命令行在本地触发管道以在云上运行该文件时,此文件才起作用。有没有解决方法,可以使我的模板上载工作而不会引发异常