有没有办法将 PubSubIO 读取转换为 UnboundedSource 源

Is there a way to convert PubSubIO read to UnboundedSource source

我想使用 PubSub subscription 作为有界源来最小化流媒体管道的成本 运行 所有 time.Similar 问题都在 Batch Pipeline with Unbounded Source but no solution. I came across this answer What PipelineRunners 之前被问到,它说我们可以转向将 UnboundedSource 转换为 BoundedSource 以便使用 withMaxNumRecords 进行测试。是否可以在此处使用 PubSubIO 作为输入,或者是否可以将 PubSubIO 读取转换为 unboundedSource

UnboundedSource<String> unboundedSource  = .; // How to Use PubSub here?
PCollection<String> boundedPubsubCollection =
    p.apply(Read.from(unboundedSource).withMaxNumRecords(10));

PubSubIO 目前还没有很好地支持它,'the Beam model' 有点奇怪。部分选项:

  1. 您是否尝试过启动您的管道并定期排空它?
  2. 如果这不起作用,您应该 post Beam 邮件列表中的功能请求或 issue tracker