lam97
lam97

Reputation: 17

Using ExecuteScript in Apache Nifi not working

I have the following flow showing in the picture attached. I am receiving 60 flowfiles from another process groups and I want them to pass through a Python script that will get executed using ExecuteScript Processor.

enter image description here

The issue now is I get no errors but none of the flow files are passed as "in" to even go through a simple script where it simply gets the ingoing flowfile, removes it and then creates a new one with the older flowfile attributes. I have some records in the queue but they are not getting into the Execute Script processor at all. I am just using this simple to test whether I can successfully run a python script or not. Here is my code :

import java.io
from org.apache.commons.io import IOUtils
from java.nio.charset import StandardCharsets
from org.apache.nifi.processor.io import StreamCallback

flowFile = session.get()
attrMap = flowFile.getAttributes()
session.remove(flowFile)
newflowFile = session.create()
newflowFile = session.putAllAttributes(newflowFile, attrMap)
session.transfer(newflowFile, REL_SUCCESS)

Here is also a picture of my configurations. Nothing else have been changed.

enter image description here

Am I missing anything ?

Edit : Settings enter image description here Scheduling enter image description here

Upvotes: 0

Views: 2003

Answers (1)

Andy
Andy

Reputation: 14184

Your code deletes the incoming flowfile from the session and then creates an unrelated new flowfile. This is not how the script should operate. The framework detects that the script isn't properly handling the data (the incoming flowfile is not transferred to any relationship), so it doesn't allow it to complete and cause data loss.

You should operate on the incoming flowfile(s) and then transfer them to the appropriate relationship. There is more information available in the Apache NiFi Developer Guide -- Common Processor Patterns and Matt Burgess' blog.

Upvotes: 2

Related Questions