Search code examples
apache-nifimerge-file

NiFi - Control de order merging two dataflows with EnforceOrder and MergeContent processor


I am trying to use the EnforceOrder processor to do a Merge in a determinate order. To do so, this is my flow: enter image description here

In the updateAttribute, I am generating an attribute to set order I want in the merge. On the one of the left, I am setting the value '1' and on the other, I am setting the value of '2'.

enter image description here

And then the configuration of the EnforceOrder is the nextone:

enter image description here

The problem is that only arrives the flow of the process.order = 1 and is not taking out the number 2. What am I doing wrong?

Cheers


Solution

  • Use EnforceOrder processor to control the order of flowfiles reaching to MergeContent processor.

    • using UpdateAttribute processor add the sequence number to the flowfile.

    Example:

    • Consider 2 flowfiles, Flowfile-2(this content will need to showup first) will have lower sequence number compared to flowfile1 then feed the success connection to MergeContent processor, By using enforceorder processor we are making sure flowfile2 will be going to Mergecontent processor before flowfile1.

    Please refer to this and use the enforce-order template to get familiar with the enforce order processor.

    UPDATE:

    I think the issue is with the EnforceOrder configs,

    • Group Identifier is configured as ${filename} so if you have two different filenames then processor doesn't wait for both of them.

    • To fix this Keep common attribute in UpdateAttribute processors like group_name as gn then use same attribute name in Group Identifier property value as ${group_name}

    • Connect Skipped and Wait connections to EnforceOrder processor it self.

    UpdateAttributeConfigs:

    enter image description here

    EnforceOrderConfigs: enter image description here

    Please use this template as reference and upload it to your NiFi instance check out how the flow has been running.