【问题标题】:How to invoke remote rest service in InvokeHttp nifi processor?如何在 InvokeHttp nifi 处理器中调用远程休息服务?
【发布时间】:2017-08-08 14:41:17
【问题描述】:
有没有办法通过invokeHttp nifi处理器调用远程休息服务并永久更改其url。在我的情况下,我需要通过 2 个参数来获取请求,并且我需要一次又一次地更改它们。是否有任何 nifi 处理器可用于将我的参数作为属性写入其中并因此将其与 invokehttp 连接?我在 invokehttp 远程 url 中的参数会改变,是否有任何处理器或多个处理器可以帮助我完成这项任务?
【问题讨论】:
标签:
rest
apache-nifi
webservices-client
【解决方案1】:
Bryan answered this with a comment 回答您之前的问题。
要在请求 URI 中提供用作参数的动态值,只需使用 Apache NiFi Expression Language 引用传入流文件上的属性。许多处理器可以提供这些属性,但UpdateAttribute 可能是您想要开始的地方。例如,如果该处理器设置了两个属性(username 和 threshold),您将拥有一系列如下流文件:
Flowfile 1 | username 'andy' | threshold '27'
Flowfile 2 | username 'bryan' | threshold '12'
Flowfile 3 | username 'sally' | threshold '22'
您的InvokeHTTP 处理器将配置一个类似https://my.remote.service:8080/incoming?username=${username}&threshold=${threshold} 的URI。因此,当流文件通过处理器时,您的传出 HTTP 请求将是:
https://my.remote.service:8080/incoming?username=andy&threshold=27
https://my.remote.service:8080/incoming?username=bryan&threshold=12
https://my.remote.service:8080/incoming?username=sally&threshold=22