I am looking for a way to create a critical section in Apache NiFi. What I mean by that is to create a group of processors in which a single FlowFile would be processed exclusively - the next FlowFile would be picked up for processing from a queue when the previous FlowFile finishes with the last processor of the group. Please refer to the picture attached below.
Bottom line: At most one FlowFile should be processed within the critical section. Concurrent task parameters applies only to a single processor, not a group of processors.
I want to implement access token management to NiFi API. I would like to keep the token in a cache and also to limit the number of requests to NiFi API.
You can readily do this in NiFi by putting the processors in the "critical section" into a process group (PG) with an input and output port. The PG can then be configured with a flowfile concurrency of "Single flowfile per node" to make it process only one flowfile at a time. If it needs to be single flowfile per cluster, you can use a loadbalancing strategy of "single node" in a connection before entering the PG.
I'm assuming you are making a custom access token flow because the one already present in the NiFi API doesn't do what you want it to, but if not, do check the documents. It leverages the configured identity providers and gives you an access token that lasts for the configured duration (12 hours by default I think).