Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ijokarumawak/654f22cea41f6c0a5672817619aeb8a7 to your computer and use it in GitHub Desktop.
Save ijokarumawak/654f22cea41f6c0a5672817619aeb8a7 to your computer and use it in GitHub Desktop.

NiFi example: How to remove specific FlowFile from a queue

Sometimes you may need to remove a specific FLowFile from a queue that causes specific issue, such as NIFI-3040. With that particular issue, RouteOnAttribute can't be used because the processor will try to generate provenance event, but the FlowFile doesn't have required attribute to do so.

In that case, ExecuteScript can route FlowFiles silently..

Use ExecuteScript to filter incoming FlowFiles

Stop the destination Processor then insert a ExecuteScript processor taking the relationship as shown below:

Then use this script to filter out FlowFiles causing the issue:

def flowFile = session.get()
if(!flowFile) return

if(flowFile.getAttribute("uuid")) {
  session.transfer(flowFile, REL_SUCCESS)
  return
}

session.transfer(flowFile, REL_FAILURE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment