Advanced Apache NiFi Flow Techniques

DZone 's Guide to

Advanced Apache NiFi Flow Techniques

Learn how to serialize NiFi flows and then reconstitute them with data and metadata at a later time and continue your flow processing.

· Big Data Zone ·
Free Resource

Let's start with FlowFile continuation.

FlowFile Continuation

Image titleSometimes, you need to backup your current running flow, let that flow run at a later date, or make a backup of what is in-process now. You want this in a permanent storage and want to reconstitute it later like orange juice and add it back into the flow or restart it.

This could be due to failures, for integration testing, for testing new versions of components, as a checkpoint, or for many other purposes. You don't always want to reprocess the original source or files (they may be gone).

Image title

Option 1

You can save that raw data that came in originally in local files or HDFS, then read it out of there later.

Option 2

Preferred: MergeContent to FlowFileV3, then reload with GET* to IdentifyMimeType to UnpackContent.

After using MergeContent with FlowFileV3, you can PutFilePutS3ObjectPutHDFS or other file saving options. Perhaps send it to an FTP or sFTP server for storage elsewhere.

Now, you have a PKG file.

cat /opt/demo/flow/904381478117605.pkg
nf.file.name904381478117605sql.args.5.value73.02sql.args.3.type3�[{"tempf": 73.02, "pressure": 1011.1, "pitch": 14.015266431562901, "temp": 33.9, "yaw": 128.4983979122009, "humidity": 29.7, "cputemp": "34", "y": -0.0, "x": -0.0, "z": 1.0, "roll": 353.9306742667328}]%

You can now reload that FlowFileV3 at any time, send it to IdentifyMimeType (so it knows it's a FlowFileV3), and then use UnpackContent to reconstitute into the original flow file. Now, you can use it like it never stopped and was sent to disk. Now you have an unlimited queue to store pre or partially processed files. This saves time! You could run really expensive processes once and save the preprocessed items, files, or models and reuse everywhere!

Choose: FlowFile Stream, v3.

Image titleImage titleThanks to Joe Witt for the explanation of this process.


big data, flows, machine learning, nifi, streaming

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}