Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

how to add output stream relationship result of Execute Stream Command processor into original flow file

avatar
Explorer
 

I need a help, I am new to NiFi. I am using python script. I wanted to add output stream relationship result of ExecuteStreamCommand processor into original flow file. In original file I am getting body and the script is generating users information. Please help me

1 ACCEPTED SOLUTION

avatar

first you need to check if there is an attribute called filename on the original flowfile and its the same passed the output stream flowfile. If there is, then you should specify it as "filename" in the merge content property and NOT as "${filename}".

View solution in original post

11 REPLIES 11

avatar
Super Mentor

@Techie123 

The ExecuteStreamCommand processor is working as designed:
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.16.2/org.apach...

Executes an external command on the contents of a flow file, and creates a new flow file with the results of the command.


You could route both the "original" and "output stream " relationships via the same outbound connection to a mergeContent processor which can merge the content from both source FlowFiles into a single FlowFile.
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.16.2/org.apach...

 

If you found this response assisted with your query, please take a moment to login and click on "Accept as Solution" below this post.

Thank you,

Matt

avatar
Explorer

Yes. But the thing is script is generating token decryption result and original flow file contains body. But the merge content processor is merging flow files randomly 

avatar
Explorer

@MattWho , can we append output stream result to original flow file without using mergeContent processor because the we have multiple incoming flow files and i just wanted to append two at a time, original flow file with the output stream result  

avatar

Is there a  unique attribute on the original flowfile (like filename) that gets set on the output stream ? if so, you can set the mergeContent processor  property "Correlation Attribute Name" to the attribute containing the unique value that is shared between original and output, this way you guarantee that only related original and output are getting merged.

avatar
Explorer

@SAMSAL , thanks for quick response. But I am new to nifi, can you please explain it a bit. you want me to add the filename explicitly? and then merged these flow files? 

avatar

how is the original flowfile is generated. usually you should have filename  attribute set by default on the original flowfile. this should be unique for the flowfile and this filename could be passed to the output stream, can you check that?

avatar
Explorer

Hi @SAMSAL , I am doing the same but still not getting the desired output.

Can you refer snapshot, Am i missing something?

Techie123_0-1655221054777.png

 

avatar

first you need to check if there is an attribute called filename on the original flowfile and its the same passed the output stream flowfile. If there is, then you should specify it as "filename" in the merge content property and NOT as "${filename}".

avatar
Explorer

Hi @SAMSAL, thanks a lot for you help. I'm getting data as expected.