Support Questions
Find answers, ask questions, and share your expertise

Implement inner loop in NIFI

Rising Star


I'm using the "splitcontent" to split messages by ',' and then every message will be split to 18 parts (splits).

Now I want to create a loop to get every single message and use the inner loop for processing each splits.

I tried to use "updateAttribute" and set "i" to "${filename}" . now i need help about inner loop (j for each i) and how to move forward in the loop.




Rising Star

Hi @Sanaz Janbakhsh,

What are you attempting to do with the fragments created from the split? Using SplitContent should produce individual flow files on your flow that contain each fragment, which can be processed in the next step (without having to loop through fragments). If you require a loop to process content within a fragment you can try using ExecuteScript to create a custom processor for your data. ExecuteScript supports multiple languages (including javascript and groovy) where you can process flow file content as needed.

Rising Star

Hi Yolanda,

I'm trying to parse truck sensors; By using ListenUDP I'm receiving all the data packet and then I use splitcontent to split up all the messages. but at the end I do have tons of fragments and so I want to group them based on a common filed such as "filename" and then transfer the group data based on each truck.

I hope the scenario is now cleared.


Rising Star

One thing I'd suggest is using ExtractText or EvaluateJsonPath (if you have Json data) after the split to search for and extract the filename field for each fragment and place it in a new flow file attribute. You could then use MergeContent to merge (group) data based on the matching filename attribute (using the correlation attribute name property). Or you could route data based on filename attribute using RouteOnAttribute to some grouped location (e.g a directory for all truck A data). Or perhaps a combination of merge and routing.