简体   繁体   中英

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.

在此处输入图像描述

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.

在此处输入图像描述

Am I missing anything?

Edit: Settings在此处输入图像描述 Scheduling在此处输入图像描述

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM