DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Build a DIY AI Model Hosting Platform With vLLM
  • Evolution of Recommendation Systems: From Legacy Rules Engines to Machine Learning
  • Personalized Search Optimization Using Semantic Models and Context-Aware NLP for Improved Results
  • Introduction to Polymorphism With Database Engines in NoSQL Using Jakarta NoSQL

Trending

  • How To Introduce a New API Quickly Using Quarkus and ChatGPT
  • Introducing Graph Concepts in Java With Eclipse JNoSQL
  • The Evolution of Scalable and Resilient Container Infrastructure
  • Supervised Fine-Tuning (SFT) on VLMs: From Pre-trained Checkpoints To Tuned Models
  1. DZone
  2. Data Engineering
  3. Data
  4. Apache NiFi With Rule Engine

Apache NiFi With Rule Engine

In this quick post, we take a look at how to use Apache NiFi, and open source big data platform, to perform data manipulation.

By 
Yehuda Korotkin user avatar
Yehuda Korotkin
·
Sep. 12, 18 · Code Snippet
Likes (3)
Comment
Save
Tweet
Share
15.7K Views

Join the DZone community and get the full member experience.

Join For Free

Combining Apache NiFi with Rule engine is easy and fun. You can do some really great stuff with data manipulation, and I wrote some code for that purpose using Drools.

Build or Download Rule Engine

Download a compiled NiFi NAR here or Build from https://github.com/alefbt/NiFi-Rule-engine-processor

This is currently working only with JSON flow files.

(Licence: Apache2)

NiFi-Rule-engine-processor github

Then run the following: 

git clone https://github.com/alefbt/NiFi-Rule-engine-processor
cd NiFi-Rule-engine-processor
mvn clean install package
cp nifi-ruleengien-processor-nar/target/nifi-ruleengien-processor-1.0.nar /path-to-nifi/lib/

And (re)start NiFi.

Example

Create a NiFi Flow

  1. GetFile Processor
    • Set property `source folder` : /some-project-path/IN
  2. RuleEngineProcessor
    • Set the property DRL file path to /some-project-path/DRL/business_object_json_test1.drl
  3. PutFile Processor
    • Set the property `dest folder` to /some-project-path/OUT

Image title

Create Files and Relevant Folders

Image title

Create a DRL file /some-project-path/DRL/business_object_json_test1.drl

package com.matrixbi.rules

import com.matrixbi.objects.BusinessObject

rule "Good Morning"
when
b: BusinessObject()
eval( b.getAsInt("time") < 12 )
then
b.set("greet","G00d Morning " + b.get("name")); 
end

rule "Good Afternoon"
when
b: BusinessObject()
eval(b.getAsInt("time") >=12 && b.getAsInt("time") < 16)
then
b.set("greet","Good Afternoon " + b.get("name"));
end

rule "Good Night"
when
b: BusinessObject()
eval(b.getAsInt("time") >= 16)
then
b.set("greet","Good Afternoon " + b.get("name"));
end

Create a JSON test file /some-project-path/IN/business_object_json_test1.json

{
"time": 11,
"greet": "Default text",
"name":"Yehuda"
}

Activate all and run it.

Result

After a few moments, you should see business_object_json_test1.json in the/some-project-path/OUT folder file.

Image title

Source

Image titleResult

Image title

Apache NiFi Engine

Opinions expressed by DZone contributors are their own.

Related

  • Build a DIY AI Model Hosting Platform With vLLM
  • Evolution of Recommendation Systems: From Legacy Rules Engines to Machine Learning
  • Personalized Search Optimization Using Semantic Models and Context-Aware NLP for Improved Results
  • Introduction to Polymorphism With Database Engines in NoSQL Using Jakarta NoSQL

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!