简体   繁体   English

将来自 2 个不同处理器的内容和属性传递给 InvokeHttp 处理器

[英]Pass Content and Attributes from 2 different Processors to InvokeHttp Processor

Here is what i am trying to do这是我想要做的

  1. Get a file and encode it to base 64获取文件并将其编码为 base 64
  2. Login to API and get OAUTH token for subsequent API calls (Since Invoke HTTP doesnt take a body so i have to pass a body using GenerateFlow processor before that) Login to API and get OAUTH token for subsequent API calls (Since Invoke HTTP doesnt take a body so i have to pass a body using GenerateFlow processor before that)

Both Steps 1 and 2 are interchangeable第 1 步和第 2 步都可以互换

  1. Now i need the token from the login call as Header value and Base64 encoded file as the body to the next Invoke Processor.现在我需要来自登录调用的令牌作为 Header 值和 Base64 编码文件作为下一个调用处理器的正文。

The problem is i am not able to connect the flows 1 and 2 so i can take them to step 3 where i need to invoke another API using the data from the 2. Both GetFile and GenerateFlow are source processors.问题是我无法连接流 1 和 2,因此我可以将它们带到第 3 步,我需要使用来自 2 的数据调用另一个 API。GetFile 和 GenerateFlow 都是源处理器。

Here is what i am thinking, to somehow convert the content to attribute.这就是我的想法,以某种方式将内容转换为属性。 Since the file is encoded in base64, is there a way i can convert that content to attribute?由于文件以 base64 编码,有没有办法可以将该内容转换为属性? i am trying to but the content is just random text, i am not sure what param to look for or what i need to put that to.我正在尝试,但内容只是随机文本,我不确定要寻找什么参数或我需要把它放在什么地方。 is there a way to say convert whatever is in the content to an attribute say filecontent="all the flow-content"有没有办法说将内容中的任何内容转换为属性说 filecontent="all the flow-content"

nifi-flow-snapshot nifi 流快照

Base 64 encoded content Base 64 编码内容

  1. First trigger both flow fro mthe same generateflowfie >> updateattribute(create common attribute to be used in merge correlation).首先从相同的 generateflowfie >> updateattribute 触发两个流(创建用于合并关联的公共属性)。
  2. Do your work做你的工作
  3. Use MergeContent - keep all unique attribute - Set correlaion using the common attribute set in out first step.使用 MergeContent - 保留所有唯一属性 - 使用第一步中设置的公共属性设置相关性。

This is how i resolved my issue for now.这就是我现在解决问题的方法。 There may be other better ways but this one worked.可能还有其他更好的方法,但这个方法有效。 Start the flow with开始流程

GetFile>>Base64Encode>>ExtractText>>ReplaceText>>Login>>continue GetFile>>Base64Encode>>ExtractText>>ReplaceText>>登录>>继续

with rest of the flow同流的rest

The trick that work was to place the ReplaceText so it can grab the entire base64 encoded content and place it in an attribute.工作的技巧是放置ReplaceText以便它可以获取整个 base64 编码内容并将其放置在属性中。 then ReplaceText will replace the entire content with the body of the login processor.然后ReplaceText将用登录处理器的主体替换整个内容。 Now i have both login token and base 64 encoded file which i can send to my next processors.现在我有登录令牌和 base 64 编码文件,我可以将它们发送到我的下一个处理器。

Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM