使用异步I/O从Flink调用http REST API [英] Call http REST api from Flink using Asynchronous I/O

查看:124
本文介绍了使用异步I/O从Flink调用http REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在从流中获取的每个数据中从flink流程元素中的Rest API中获取数据,我如何才能实现这一点,我找不到足够的材质来异步调用Rest服务.请为我提供一些示例文章.

i have to fetch data from Rest API from flink process element in every data fetch from the stream, how can i achive that, i couldnt find enough meterials to call the Rest service asynchronously. please help me with some sample articles.

推荐答案

所有工作都发生在 RichAsyncFunction asyncInvoke 中.因此,为了能够调用REST服务,您需要使用一些异步HTTP客户端(从技术上讲,它可以是同步客户端,但这没有任何意义).可以在此处找到一个使用HTTP异步客户端的示例.

All the job is happening inside the asyncInvoke of the RichAsyncFunction. So, to be able to call REST service, You need to use some async HTTP client (technically it could be a synchronous client but this doesn't make sense). An example of async http client usage can be found here.

因此,当您执行异步请求时,您所需要做的就是在请求处理程序中调用 resultFuture.complete ,以便将结果传递到Flink的下游.

So, when You execute the async request all You need to do, is to call resultFuture.complete in Your request handler, so that the result is passed downstream in Flink.

这篇关于使用异步I/O从Flink调用http REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆