Search code examples
apache-nifi

Forward only one flowfile from multiple same flowfiles


I have multiple flowfile as an output of spitjson processor , all are same flowfile with same content . I just want to forward one flowfile . Is there a way to do that in nifi


Solution

  • yes it should be possible.

    splitjson processor write fragment.index attribute to each flowfile

    A one-up number that indicates the ordering of the split FlowFiles that were created from a single parent FlowFile

    each flowfile will receive a unique fragment.index starting from 1 to number of flowfile

    so you can use route on attribute to only keeper flowfile with fragment.index equal to 1

    Flow :

    enter image description here

    input data :

    [{"name":"Gayle Hays"},{"name":"Merritt Calhoun"},{"name":"Tamara Lane"},{"name":"Contreras Heath"},{"name":"Martinez Watson"}]
    

    RouteOnAttribute processor configuration:

    enter image description here

    Documentation : https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.12.1/org.apache.nifi.processors.standard.SplitJson/index.html