如何在 InvokeHttp nifi 处理器中调用远程休息服务?

How to invoke remote rest service in InvokeHttp nifi processor?

有没有办法通过 invokeHttp nifi 处理器调用远程休息服务并永久更改其 url。在我的例子中,我需要传递 2 个参数来获取请求,并且我需要一次又一次地更改它们。是否有任何 nifi 处理器可用于将我的参数作为属性写入其中并随后将其与 invokehttp 连接?我在 invokehttp remote url 中的参数会改变,是否有处理器或多个处理器可以帮助我完成此任务?

Bryan 回答了您之前的问题。

要提供在请求 URI 中用作参数的动态值,使用 Apache NiFi Expression Language. Many processors can provide those attributes, but UpdateAttribute 简单地引用传入流文件上的属性可能是您想要开始的地方。例如,如果该处理器设置了两个属性(usernamethreshold),您将拥有一系列如下的流文件:

  1. Flowfile 1 | username 'andy' | threshold '27'
  2. Flowfile 2 | username 'bryan' | threshold '12'
  3. Flowfile 3 | username 'sally' | threshold '22'

您的 InvokeHTTP 处理器将配置一个类似 https://my.remote.service:8080/incoming?username=${username}&threshold=${threshold} 的 URI。因此,当流文件通过处理器时,您的传出 HTTP 请求将是:

  1. https://my.remote.service:8080/incoming?username=andy&threshold=27
  2. https://my.remote.service:8080/incoming?username=bryan&threshold=12
  3. https://my.remote.service:8080/incoming?username=sally&threshold=22