如何使用直接运行程序在 Eclipse 中调试 Dataflow/Apache Beam 管道 DoFn 函数

How to debug Dataflow/Apache Beam pipeline DoFn functions in eclipse using direct runner

我想在 eclipse 中使用 direct runner 运行 我的管道,并在我的 DoFn 函数和调试执行中放置一个断点。我尝试通过以下步骤直接设置 运行ner:

  1. 添加直接运行ner maven包
  2. 在 pom.xml 中为直接 运行ner 设置 maven 配置文件。我的 pom.xml 有 this profile

<profiles> <profile> <id>direct-runner</id> <activation> <activeByDefault>true</activeByDefault> </activation> <dependencies> <dependency> <groupId>org.apache.beam</groupId> <artifactId>beam-runners-direct-java</artifactId> <version>0.2.0-incubating</version> </dependency> </dependencies> </profile> </profiles>

  1. 我的 pom.xml
  2. 中有 this 插件管理下的 maven 插件

<pluginManagement> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.4.0</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <cleanupDaemonThreads>false</cleanupDaemonThreads> <mainClass>com.MyMainClass</mainClass> </configuration> </plugin> </plugins> </pluginManagement>

  1. 下面是我的 eclipse 调试配置的屏幕截图 当我 运行 使用上面的调试配置作业时,在 GCP 数据流而不是本地 JVM 线程中启动并且我的断点永远不会命中。

可能是您在测试方法中创建管道的方式。尝试使用 TestPipeline util class 像这样

创建管道
public TestPipeline p = TestPipeline.create();