Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify priority attributes for individual flowfiles?

Tags:

apache-nifi

I need to use PrioritizeAttributePrioritizer in NiFi.

i have observed that prioritizers in below reference. https://nifi.apache.org/docs/nifi-docs/html/user-guide.html#settings

if i receive 10 flowfiles then i need to set the priority value for every flow file to be unique.

After that specify queue configuration must be PrioritizeAttributePrioritizer.

Then processing flowfiles based on priority value.

How can i set priority value for seperate flow files or which prioritizer in Nifi to be work for my case?

like image 916
Mister X Avatar asked Dec 01 '22 15:12

Mister X


1 Answers

The PriorityAttributePrioritizer prioritizes flow files by looking for a flow file attribute named "priority" and sorting the flow files lexicographically based on the value of the priority.

You can set the priority attribute using an UpdateAttribute processor. For example, if you had three logical data feeds, and feed #1 was most important, feed #2 was second most important, and feed #3 was third, then you could use three UpdateAttribute processors to set the priority attribute to 1, 2, and 3, then use a funnel to converge them all.

You would set the PriorityAttributePrioritizer on the queue between the funnel and the next processor, and at this point any time a flow file with priority=1 hits the queue, it will always be processed before any flow files with priority=2 and priority=3.

Determining how to set the priority really depends on your data. It is usually based on something about the data, like a field from each flow file that is extracted to an attribute to tell it the priority, or just knowing that everything that comes from source #1 is higher priority than what comes from source #2. Setting randomly unique priorities doesn't really make sense because you don't even know what you are prioritizing on then.

like image 83
Bryan Bende Avatar answered May 02 '23 08:05

Bryan Bende