How to do Async Http Call with Apache Beam (Java)?

前端 未结 2 1756
深忆病人
深忆病人 2020-12-22 02:19

Input PCollection is http requests, which is a bounded dataset. I want to make async http call (Java) in a ParDo , parse response and put results into output PCollection. My

相关标签:
2条回答
  • 2020-12-22 02:55

    The Scio library implements a DoFn which deals with asynchronous operations. The BaseAsyncDoFn might provide you the handling you need. Since you're dealing with CompletableFuture also take a look at the JavaAsyncDoFn.

    Please note that you necessarily don't need to use the Scio library, but you can take the main idea of the BaseAsyncDoFn since it's independent of the rest of the Scio library.

    0 讨论(0)
  • 2020-12-22 03:14

    The issue that your hitting is that your outputting outside the context of a processElement or finishBundle call.

    You'll want to gather all your outputs in memory and output them eagerly during future processElement calls and at the end within finishBundle by blocking till all your calls finish.

    0 讨论(0)
提交回复
热议问题