- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to manipulate text in NiFi processor IDE?
- Labels:
-
Apache NiFi
Created ‎02-23-2016 04:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to develop a custom processor to manipulate flowfile contents via Java. However, I am not sure how constructors are used for the flowfile contents. As a simplified example, how can I create a custom processor that replaces the letter A with the letter Z in a flowfile content?
Created ‎02-23-2016 05:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For replacing contents of an incoming flowfile, the write(FlowFile, StreamCallback) method of ProcessSession is probably your best bet. There is a corresponding section of the NiFi Developer's Guide.
There is an example of this in the ReplaceText processor code under the AlwaysReplace strategy.
As an alternative to creating a full-fledged custom processor, as of NiFi 0.5.0 there are the InvokeScriptedProcessor and ExecuteScript processors. You can use InvokeScriptedProcessor to use a scripting language like Groovy to provide a Processor implementation, which avoids the need for building and deploying your own NARs. If you don't need a full processor and are just looking to manipulate the flowfile content, you could use the ExecuteScript processor, which allows easy access to incoming flowfiles and such.
I've written a blog post on using ExecuteScript (with Groovy) to replace flowfile contents: http://funnifi.blogspot.com/2016/02/executescript-processor-replacing-flow.html
Regards,
Matt
Created ‎02-23-2016 05:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For replacing contents of an incoming flowfile, the write(FlowFile, StreamCallback) method of ProcessSession is probably your best bet. There is a corresponding section of the NiFi Developer's Guide.
There is an example of this in the ReplaceText processor code under the AlwaysReplace strategy.
As an alternative to creating a full-fledged custom processor, as of NiFi 0.5.0 there are the InvokeScriptedProcessor and ExecuteScript processors. You can use InvokeScriptedProcessor to use a scripting language like Groovy to provide a Processor implementation, which avoids the need for building and deploying your own NARs. If you don't need a full processor and are just looking to manipulate the flowfile content, you could use the ExecuteScript processor, which allows easy access to incoming flowfiles and such.
I've written a blog post on using ExecuteScript (with Groovy) to replace flowfile contents: http://funnifi.blogspot.com/2016/02/executescript-processor-replacing-flow.html
Regards,
Matt
Created ‎02-29-2016 07:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using nifi-0.4.0. This version does not have the ExecuteScript processor. How can I install this processor and configure the processor to run a Java program?
-KS
