[ 
https://issues.apache.org/jira/browse/NIFI-14480?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17945226#comment-17945226
 ] 

Naman Arora commented on NIFI-14480:
------------------------------------

Thanks for the guidance [~exceptionfactory] — I think all of those are great 
points. Here’s how I’d like to address them:

*1. Public Drools+JSON examples*
 * You’re absolutely right — many enterprise Drools integrations aren’t 
open-sourced, which limits the number of public examples. To make things 
crystal clear for reviewers, I’ll include concise, self-contained code snippets 
in the extension’s README that show exactly how a JSON payload can be 
deserialized and processed with Drools.

 

Here’s a generic working snippet:
{code:java}
// Deserialize JSON to Map
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> jsonPayload = mapper.readValue(inputStream, new 
TypeReference<>(){});
// Insert into Drools session
KieSession kieSession = kieContainer.newKieSession();
kieSession.insert(jsonPayload);
kieSession.fireAllRules();
kieSession.dispose();
{code}
 * Additionally, there are some useful open-source projects like [this 
one|https://github.com/ityouknow/drools-examples] that showcase Drools usage 
more broadly.

*2. Streaming vs. full parse*
 * Under the hood, Drools rules execute against Java objects, so you’ll need to 
deserialize the JSON (we’ll use Jackson). However, we can integrate this into a 
streaming approach by using Jackson’s {{Streaming API}} ({{{}JsonParser{}}}) 
and constructing rule‐target objects incrementally, rather than loading the 
entire JSON tree into memory first. I’ll include a proof‑of‑concept that reads 
the incoming {{InputStream}} in chunks, maps fields on the fly, and fires rules 
as data arrives.

*3. Dedicated NAR bundle*
 * I agree that a separate {{nifi-drools-nar}} makes sense for clarity and 
maintainability. I’ll set up the Maven modules accordingly so it can be 
contributed as an extension without touching {{{}nifi-standard{}}}.

*4. Processor name*
 * *DroolsTransformJSON* fits nicely with our existing pattern—happy to stick 
with that.

Thanks again for your feedback

Best,
Naman

> Add DroolsProcessor for rule-based JSON processing with dynamic/static DRL 
> support
> ----------------------------------------------------------------------------------
>
>                 Key: NIFI-14480
>                 URL: https://issues.apache.org/jira/browse/NIFI-14480
>             Project: Apache NiFi
>          Issue Type: New Feature
>          Components: Extensions
>            Reporter: Naman Arora
>            Priority: Major
>
> This processor provides integration of the Drools Rule Engine with Apache 
> NiFi. It allows for flexible rule-based processing of JSON payloads in two 
> modes:
> 1. **Static DRL Mode**:
>    - User provides an absolute path to a DRL file.
>    - That rule is used for all incoming flowfiles.
> 2. **Dynamic DRL Mode**:
>    - User specifies a base path and a key name.
>    - Processor extracts the relative DRL path from the key inside the 
> flowfile JSON payload.
>    - Dynamically fetches the rule and executes it.
> Additional Features:
> - **File Watcher** service that watches static and dynamic paths for DRL file 
> changes and reloads the KIE Container automatically.
> - **Retry Mechanism** for rule execution with configurable retry attempts.
> This processor supports advanced decisioning and rule separation, and helps 
> enable dynamic business rule application inside NiFi dataflows.
> I would like to contribute this processor under the Apache License. I have 
> signed and submitted the ICLA.
> Let me know the next steps or if any feedback is required. Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to