NiFi Dynamic Script Executors
Work-in-Progress
The goal of this project is to enable processing NiFi FlowFiles using scripting languages.
- ExecuteJavaScript Usage: JSON -> Mapping -> JSON
- ExecuteGroovy execute supplied groovy script with arguments configured.
- Manual: Download Apache NiFi binaries and unpack to a folder.
- On Mac: brew install nifi
# Assume you unpacked nifi-0.3.0-bin.zip to /Developer/Applications/nifi
./gradlew clean deploy -Pnifi_home=/Developer/Applications/nifi
On Mac
gradle clean deploy -Pnifi_home=/usr/local/Cellar/nifi/0.3.0/libexec
cd /Developer/Applications/nifi
./bin/nifi.sh start
./bin/nifi.sh stop
On Mac
# nifi start|stop|run|restart|status|dump|install
nifi start
nifi status
nifi stop
# Working Directory: /usr/local/Cellar/nifi/0.3.0/libexec
Upload the sample flow into NiFi and use test data and below javascript for testing:
function convert(val) {
var g = JSON.parse(val);
var d = {
widget: g.widget.window.title,
imageURI: g.widget.image.src
};
return JSON.stringify(d);
}
print("Hello from inside scripting!");
var fs = util.flowFileToString(flowFile, session);
log.error(fs);
var flowString = convert(fs);
log.error(flowString);
//flowFile = session.importFrom(buff, true, flowFile);
session.remove(flowFile);
flowFile = util.stringToFlowFile(flowString, session);
flowFile = session.putAttribute(flowFile, "JS", 2222 );
- Support adding popular javaScript libraries (lodash.js, moment.js etc.,) via processor configuration.