NiFi - Choose Queue to execute

Suppose you have an ExecuteScript processor in a NiFi flow. This processor has 2 incoming queues.

Is there a way to choose from which Queue session.get() will pull the flowfile?

Thanks.

Upvotes: 1

Views: 788

Answers (1)

mattyb
mattyb

Reputation: 12103

There's no direct way via the API to identify which queue a flow file is coming from. However you can try this:

  • Add an UpdateAttribute to each upstream flow before ExecuteScript. For each branch, add the same attribute with a different value, say "queue.name" = "A" for one and "queue.name" = "B" for the other
  • In ExecuteScript you can pass a FlowFileFilter to session.get(), to fetch flow file(s) whose queue.name attribute is "A" or "B". Note that you may get an empty list, and if you need at least one flow file to continue, you can just return if the list is empty.

Upvotes: 1

Related Questions