Apache Nifi is a Data Flow Management system. Apache Velocity is a Template Engine. I have used Velocity for many years now: it is a swiss-army knife for converting or formatting data. And I have used it in web applications to separate the design - the web pages - from the code. Groovy (I used Beanshell as well) does the work to get the data and apply logic and Velocity is responsible for the visual display.
Now that I have spent some time with Apache Nifi, I wanted to write my first processor (like a puzzle piece) for it and as Velocity is straight forward and I know it well, I decided to start a little project.
The idea is, that in Nifi there is data arriving and that data is formatted through the template engine. Here is an example of one row from the data:
Peterson, Jenny, New York, USA
And the simple idea is to reformat it to Json like this:
{
"name": "Peterson",
"first": "Jenny",
"city": "New York",
"country": "USA"
}
To achieve this simply create a template. Replace the actual data in the Json above with placeholders like this:
{
"name": "$column_000",
"first": "$column_001",
"city": "$column_002",
"country": "$column_003"
}