SlideShare a Scribd company logo
1 of 16
Download to read offline
Integrating DROOLS With Mule ESB
JITENDRA BAFNA
Integrating DROOLS With Mule ESB
Overview
DROOLS is Business Logic integration platform (BLiP). It is written in Java. It is an
open source that is backed by RedHat and JBoss. It is Business Rules Management
System (BRMS) solution. It provides a core Business Rules Engine (BRE), a web
authoring and rules management application (Drools Workbench) and an Eclipse
IDE plugin for core development. It is one of the best open source rule engine
provides Complex Event Processing.
Facts are stored in working memory (like in-memory database), Fact is piece of
data, such as salary=3000 or in object oriented rules engine, it may be java object
with properties.
Rules are defined in a knowledge base.A rule consists of conditions (which
typically depend on facts in the working memory) and actions which are executed
when the conditions are true (similar to an "if-then" statement).
Integrating DROOLS With Mule ESB
Advantages Of DROOLS Rules Engine
• Reusability: The rules are kept at some centralized location (separation of business logic from
rest of system), it is easy to reuse Drools rules engine.
• Flexibility: Changing the application or its model is not easy task but it is very easy to change the
rules than Java code.
• Redeploying: It is easy to redeploy modified rules without stopping or modifying the application
logic.
• Easier To Understand: It is easier to understand the rules for new developers that code written in
java or any other languages.
• You can avoid lot of if-else from your actual business logic by separating or implementing
business rules separately.
• Unifying: The Drools platform brings unification of rules and processes. It is easy to call rules
from a process or vice versa.
• Easy to implement Complex logic using Drools Rules Engine.
Integrating DROOLS With Mule ESB
Considerations for Using Drools Rule Engine
• Let consider that DROOLS should be used when your Business Logic is very
complex. Apart from complex business logic, you can use Drools in below
situations
• Application business logic often change.
• Business Logic contains lot of If-Else statements.
• The business logic is overly complex or time-consuming when defined
procedurally.
• The business logic needs to be maintained by people who don’t (or shouldn’t)
have access to the application itself (to recompile/redeploy it).
• Domain experts (or business analysts) are readily available, but are nontechnical.
Integrating DROOLS With Mule ESB
BusinessUseCase
Todaywe will goingto implementbusinessuse case such as Life insurance
policy,dependingon age and policytype,we will be providingpremium amount.Below is
the logicsfor our businesscases
• If age < 10 and policyType= "Policy1",then premiumAmount= 20000.
• If age is between 10 and 40 and policyType= "Policy1", then premiumAmount= 30000.
• If age > 40 and policyType= "Policy1", then premiumAmount= 40000.
• If age < 10 and policyType= "Policy2",then premiumAmount =21000.
• If age is between 10 and 40 and policyType= "Policy2", then premiumAmount =32000.
• If age > 40 and policyType= "Policy2", then premiumAmount= 43000.
Our flow willreceive belowJSON messageand we will use JSON data to pass throughour
rules engine.
Integrating DROOLS With Mule ESB
Once JSON message passed through Rules Engine and our expected output is
shown below.
Integrating DROOLS With Mule ESB
Implementing DROOLS With Mule ESB
Now, we will walkthrough how to integrate the Mule ESB and Java rules engine
namely DROOLS.
Create Mule project and named the project droolsexample.xml and you can select
Mule runtime 3.6 or higher.
NamespaceAnd Schema
First thing we need to add namespace and schema location to mule configuration
file (e.g. droolsexample.xml).
Integrating DROOLS With Mule ESB
Initialize BPM Rules
Add below tag in droolsdemo.xml and it will tell the mule flow there is some rules
defined in your flow and it will start DROOL's working memory.
Defining Mule Flow With DROOLS Rules
We will be receiving the JSON message and it will be converted into Java object
using JSONTo Object transformer. Our Java class for Insurance will look like this:
Integrating DROOLS With Mule ESB
package com.drools.example;
publicclass Insurance {
private String name;
private int age;
private String policyType;
private int premiumAmount;
publicString getName()
{
return name;
}
publicvoid setName(String name)
{
this.name=name;
}
publicint getAge()
{
return age;
}
publicvoid setAge(intage)
{
this.age=age;
}
publicString getPolicyType()
{
return policyType;
}
publicvoid setPolicyType(String policyType)
{
this.policyType=policyType;
}
publicint getPremiumAmount()
{
return premiumAmount;
}
publicvoid setPremiumAmount(intpremiumAmount)
{
this.premiumAmount=premiumAmount;
}
}
Add file with .drl extension to your classpath (src/main/resources). This file will contains all rules in plaintext
which can be easily modified and loaded at runtime if needed.
Integrating DROOLS With Mule ESB1
package com.drools.example
import org.mule.MessageExchangePattern;
import com.drools.example.Insurance;
global org.mule.module.bpm.MessageService mule;
dialect "mvel"
declare Insurance
@role('event')
end
rule "Policy 1 And Infant"
lock - on - active when
$insurance: Insurance(age <10 && policyType =="Policy1") then
modify($insurance) {
setPremiumAmount(20000)
}
end
rule "Policy 1 And Adult"
lock - on - active when
$insurance: Insurance((age >=10&&age <= 40) && policyType =="Policy1") then
modify($insurance) {
setPremiumAmount(30000)
}
end
rule"Policy1 And Older"
lock - on - active when
$insurance: Insurance(age >40 && policyType =="Policy1") then
modify($insurance) {
setPremiumAmount(40000)
}
end
rule "Policy 2 And Infant"
lock - on - active when
$insurance: Insurance(age <10 && policyType =="Policy2") then
modify($insurance) {
setPremiumAmount(21000)
}
end
rule "Policy 2 And Adult"
lock - on - active when
$insurance: Insurance((age >=10&&age <= 40) && policyType =="Policy2") then
modify($insurance) {
setPremiumAmount(31000)
}
end
rule"Policy2 And Older"
lock - on - active when
$insurance: Insurance(age >40 && policyType =="Policy2") then
modify($insurance) {
setPremiumAmount(41000)
}
end
Integrating DROOLS With Mule ESB
In rule file, we have defined import namespaces and packages statements.Then
we create the Insurance object to be used by our rule engine and followed by some
rules with conditions that explained earlier.
Define Spring Beans
You need to define spring beans in your configuration file (e.g. droolsexample.xml)
as shown below
Integrating DROOLS With Mule ESB
Call Rule Definition in Mule Flow
• Rule Definition can be call in Mule flow by defining below statement in
configuration file (droolsexample.xml)
Integrating DROOLS With Mule ESB
Mule Flow [Code]
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json"xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq"xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:bpm="http://www.mulesoft.org/schema/mule/bpm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/httphttp://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/ee/wmqhttp://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd
http://www.mulesoft.org/schema/mule/bpmhttp://www.mulesoft.org/schema/mule/bpm/current/mule-bpm.xsd">
<bpm:drools/>
<spring:beans>
<spring:bean name="NoFactsBean" class="java.util.ArrayList"/>
</spring:beans>
<http:listener-configname="HTTP_Listener_Configuration" host="0.0.0.0" port="8081"doc:name="HTTPListenerConfiguration"/>
<flow name="mule-proj-flowFlow">
<http:listenerconfig-ref="HTTP_Listener_Configuration" path="/drools"allowedMethods="POST" doc:name="HTTP"/>
<wmq:object-to-message-transformer doc:name="Objectto Message"/>
<json:json-to-object-transformer returnClass="com.drools.example.Insurance" doc:name="JSON to Object"/>
<bpm:rules rulesDefinition="insuranceRules.drl"initialFacts-ref="NoFactsBean" doc:name="BPMRules"/>
<set-payload value="#[payload.object]" doc:name="SetPayload"/>
<json:object-to-json-transformer doc:name="Object toJSON"/>
</flow>
</mule>
Integrating DROOLS With Mule ESB
Testing
We will use postman to test all the above scenarios and hopefully, we will get
expected result back.
Integrating DROOLS With Mule ESB
Conclusion
Mule provided easy steps to integrate with DROOLS and same is explained in
above article. I hope you find this article interesting and provided required
information to integrate DROOLS with Mule flow.
ThankYou.

More Related Content

What's hot

MuleSoft Surat Virtual Meetup#31 - Async API, Process Error, Circuit Breaker ...
MuleSoft Surat Virtual Meetup#31 - Async API, Process Error, Circuit Breaker ...MuleSoft Surat Virtual Meetup#31 - Async API, Process Error, Circuit Breaker ...
MuleSoft Surat Virtual Meetup#31 - Async API, Process Error, Circuit Breaker ...Jitendra Bafna
 
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...Jitendra Bafna
 
Elastic and Cloud-ready Applications with Payara Micro
Elastic and Cloud-ready Applications with Payara MicroElastic and Cloud-ready Applications with Payara Micro
Elastic and Cloud-ready Applications with Payara MicroOndrej MihĂĄlyi
 
Anypoint connector dev kit
Anypoint connector dev kitAnypoint connector dev kit
Anypoint connector dev kitD.Rajesh Kumar
 
SpringPeople Introduction to MongoDB Administration
SpringPeople Introduction to MongoDB AdministrationSpringPeople Introduction to MongoDB Administration
SpringPeople Introduction to MongoDB AdministrationSpringPeople
 
mulesoft birmingham meetup_api_designing_with_raml
mulesoft birmingham meetup_api_designing_with_ramlmulesoft birmingham meetup_api_designing_with_raml
mulesoft birmingham meetup_api_designing_with_ramlmohammadsakifuddin
 
Mule 3.4 features
Mule 3.4 featuresMule 3.4 features
Mule 3.4 featureshimajareddys
 
Reactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring BootReactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring BootVMware Tanzu
 
Migrating to mule 4 - Are you ready for This.
Migrating to mule 4 - Are you ready for This.Migrating to mule 4 - Are you ready for This.
Migrating to mule 4 - Are you ready for This.Harish Kumar
 
SpringPeople Introduction to Mule ESB
SpringPeople Introduction to Mule ESBSpringPeople Introduction to Mule ESB
SpringPeople Introduction to Mule ESBSpringPeople
 
Mule anypoint exchange
Mule  anypoint exchangeMule  anypoint exchange
Mule anypoint exchangeD.Rajesh Kumar
 
Cloudify Open PaaS Stack for DevOps
Cloudify Open PaaS Stack for DevOps  Cloudify Open PaaS Stack for DevOps
Cloudify Open PaaS Stack for DevOps Nati Shalom
 
Mule hdfs connector
Mule hdfs connectorMule hdfs connector
Mule hdfs connectorD.Rajesh Kumar
 
Mule UDP Transport
Mule UDP TransportMule UDP Transport
Mule UDP TransportAnkush Sharma
 
Shipping your logs to elk from mule app/cloudhub part 1
Shipping  your logs to elk from mule app/cloudhub   part 1Shipping  your logs to elk from mule app/cloudhub   part 1
Shipping your logs to elk from mule app/cloudhub part 1Alex Fernandez
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafkamarius_bogoevici
 
Mule database-connectors
Mule  database-connectorsMule  database-connectors
Mule database-connectorsD.Rajesh Kumar
 

What's hot (19)

MuleSoft Surat Virtual Meetup#31 - Async API, Process Error, Circuit Breaker ...
MuleSoft Surat Virtual Meetup#31 - Async API, Process Error, Circuit Breaker ...MuleSoft Surat Virtual Meetup#31 - Async API, Process Error, Circuit Breaker ...
MuleSoft Surat Virtual Meetup#31 - Async API, Process Error, Circuit Breaker ...
 
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
MuleSoft Surat Virtual Meetup#30 - Flat File Schemas Transformation With Mule...
 
Elastic and Cloud-ready Applications with Payara Micro
Elastic and Cloud-ready Applications with Payara MicroElastic and Cloud-ready Applications with Payara Micro
Elastic and Cloud-ready Applications with Payara Micro
 
Mule rabbitmq
Mule rabbitmqMule rabbitmq
Mule rabbitmq
 
Anypoint connector dev kit
Anypoint connector dev kitAnypoint connector dev kit
Anypoint connector dev kit
 
SpringPeople Introduction to MongoDB Administration
SpringPeople Introduction to MongoDB AdministrationSpringPeople Introduction to MongoDB Administration
SpringPeople Introduction to MongoDB Administration
 
mulesoft birmingham meetup_api_designing_with_raml
mulesoft birmingham meetup_api_designing_with_ramlmulesoft birmingham meetup_api_designing_with_raml
mulesoft birmingham meetup_api_designing_with_raml
 
Mule 3.4 features
Mule 3.4 featuresMule 3.4 features
Mule 3.4 features
 
Reactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring BootReactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring Boot
 
Migrating to mule 4 - Are you ready for This.
Migrating to mule 4 - Are you ready for This.Migrating to mule 4 - Are you ready for This.
Migrating to mule 4 - Are you ready for This.
 
SpringPeople Introduction to Mule ESB
SpringPeople Introduction to Mule ESBSpringPeople Introduction to Mule ESB
SpringPeople Introduction to Mule ESB
 
Mule anypoint exchange
Mule  anypoint exchangeMule  anypoint exchange
Mule anypoint exchange
 
Cloudify Open PaaS Stack for DevOps
Cloudify Open PaaS Stack for DevOps  Cloudify Open PaaS Stack for DevOps
Cloudify Open PaaS Stack for DevOps
 
Mule hdfs connector
Mule hdfs connectorMule hdfs connector
Mule hdfs connector
 
Mule UDP Transport
Mule UDP TransportMule UDP Transport
Mule UDP Transport
 
Shipping your logs to elk from mule app/cloudhub part 1
Shipping  your logs to elk from mule app/cloudhub   part 1Shipping  your logs to elk from mule app/cloudhub   part 1
Shipping your logs to elk from mule app/cloudhub part 1
 
Developing real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and KafkaDeveloping real-time data pipelines with Spring and Kafka
Developing real-time data pipelines with Spring and Kafka
 
Mule rabbit mq
Mule rabbit mqMule rabbit mq
Mule rabbit mq
 
Mule database-connectors
Mule  database-connectorsMule  database-connectors
Mule database-connectors
 

Similar to Integrating DROOLS

Droolsand Rule Based Systems 2008 Srping
Droolsand Rule Based Systems 2008 SrpingDroolsand Rule Based Systems 2008 Srping
Droolsand Rule Based Systems 2008 SrpingSrinath Perera
 
Rule Engine & Drools
Rule Engine & DroolsRule Engine & Drools
Rule Engine & DroolsSandip Jadhav
 
JBoss Drools - Pure Java Rule Engine
JBoss Drools - Pure Java Rule EngineJBoss Drools - Pure Java Rule Engine
JBoss Drools - Pure Java Rule EngineAnil Allewar
 
Adavanced faulthandling
Adavanced faulthandlingAdavanced faulthandling
Adavanced faulthandlingXAVIERCONSULTANTS
 
Adavanced faulthandling
Adavanced faulthandlingAdavanced faulthandling
Adavanced faulthandlingxavier john
 
Drools in Mule
Drools in MuleDrools in Mule
Drools in MuleMohammed246
 
Mule with drools
Mule with drools Mule with drools
Mule with drools Rajkattamuri
 
Mule with drools
Mule with droolsMule with drools
Mule with droolsHasan Syed
 
Mule with drools
Mule with droolsMule with drools
Mule with droolsSunil Komarapu
 
Mule with drools
Mule with droolsMule with drools
Mule with droolsjaveed_mhd
 
Mule with drools
Mule with drools Mule with drools
Mule with drools mdfkhan625
 
Mule with drools
Mule with droolsMule with drools
Mule with droolsF K
 
Mule with drools
Mule with drools Mule with drools
Mule with drools Mohammed625
 
Mule with drools
Mule with droolsMule with drools
Mule with droolsKhan625
 
Vpd Virtual Private Database By Saurabh
Vpd   Virtual Private Database By SaurabhVpd   Virtual Private Database By Saurabh
Vpd Virtual Private Database By Saurabhguestd83b546
 

Similar to Integrating DROOLS (20)

Drools rule Concepts
Drools rule ConceptsDrools rule Concepts
Drools rule Concepts
 
Droolsand Rule Based Systems 2008 Srping
Droolsand Rule Based Systems 2008 SrpingDroolsand Rule Based Systems 2008 Srping
Droolsand Rule Based Systems 2008 Srping
 
Rule Engine & Drools
Rule Engine & DroolsRule Engine & Drools
Rule Engine & Drools
 
JBoss Drools - Pure Java Rule Engine
JBoss Drools - Pure Java Rule EngineJBoss Drools - Pure Java Rule Engine
JBoss Drools - Pure Java Rule Engine
 
Adavanced faulthandling
Adavanced faulthandlingAdavanced faulthandling
Adavanced faulthandling
 
Adavanced faulthandling
Adavanced faulthandlingAdavanced faulthandling
Adavanced faulthandling
 
Drools in Mule
Drools in MuleDrools in Mule
Drools in Mule
 
Mule drools
Mule drools Mule drools
Mule drools
 
Mule with drools
Mule with drools Mule with drools
Mule with drools
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
 
Mule with drools
Mule with drools Mule with drools
Mule with drools
 
Mule with drools
Mule with drools Mule with drools
Mule with drools
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
 
Mule with drools
Mule with drools Mule with drools
Mule with drools
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
 
Mule with drools
Mule with droolsMule with drools
Mule with drools
 
Vpd
VpdVpd
Vpd
 
Vpd Virtual Private Database By Saurabh
Vpd   Virtual Private Database By SaurabhVpd   Virtual Private Database By Saurabh
Vpd Virtual Private Database By Saurabh
 

More from Jitendra Bafna

MuleSoft Surat Meetup#55 - Unleash the power of Anypoint MQ
MuleSoft Surat Meetup#55 - Unleash the power of Anypoint MQMuleSoft Surat Meetup#55 - Unleash the power of Anypoint MQ
MuleSoft Surat Meetup#55 - Unleash the power of Anypoint MQJitendra Bafna
 
MuleSoft Surat Meetup#54 - MuleSoft Automation
MuleSoft Surat Meetup#54 - MuleSoft AutomationMuleSoft Surat Meetup#54 - MuleSoft Automation
MuleSoft Surat Meetup#54 - MuleSoft AutomationJitendra Bafna
 
MuleSoft Surat Meetup#53 - MuleSoft for Clinical Trial Modernization
MuleSoft Surat Meetup#53 - MuleSoft for Clinical Trial ModernizationMuleSoft Surat Meetup#53 - MuleSoft for Clinical Trial Modernization
MuleSoft Surat Meetup#53 - MuleSoft for Clinical Trial ModernizationJitendra Bafna
 
MuleSoft Surat Meetup#52 - Flex Gateway (Port Based Routing V/S Path Based Ro...
MuleSoft Surat Meetup#52 - Flex Gateway (Port Based Routing V/S Path Based Ro...MuleSoft Surat Meetup#52 - Flex Gateway (Port Based Routing V/S Path Based Ro...
MuleSoft Surat Meetup#52 - Flex Gateway (Port Based Routing V/S Path Based Ro...Jitendra Bafna
 
MuleSoft Surat Meetup#51 - API Monitoring - Through a New Lens
MuleSoft Surat Meetup#51 - API Monitoring - Through a New LensMuleSoft Surat Meetup#51 - API Monitoring - Through a New Lens
MuleSoft Surat Meetup#51 - API Monitoring - Through a New LensJitendra Bafna
 
Engineering Student MuleSoft Meetup#7 - Leveraging MuleSoft Service in Salesf...
Engineering Student MuleSoft Meetup#7 - Leveraging MuleSoft Service in Salesf...Engineering Student MuleSoft Meetup#7 - Leveraging MuleSoft Service in Salesf...
Engineering Student MuleSoft Meetup#7 - Leveraging MuleSoft Service in Salesf...Jitendra Bafna
 
MuleSoft Nashik Meetup#7 - Building FHIR applications in MongoDB using MuleSoft
MuleSoft Nashik Meetup#7 - Building FHIR applications in MongoDB using MuleSoftMuleSoft Nashik Meetup#7 - Building FHIR applications in MongoDB using MuleSoft
MuleSoft Nashik Meetup#7 - Building FHIR applications in MongoDB using MuleSoftJitendra Bafna
 
MuleSoft Surat Meetup#50 - Ask the MuleSoft Ambassadors + CloudHub 2.0 Overvi...
MuleSoft Surat Meetup#50 - Ask the MuleSoft Ambassadors + CloudHub 2.0 Overvi...MuleSoft Surat Meetup#50 - Ask the MuleSoft Ambassadors + CloudHub 2.0 Overvi...
MuleSoft Surat Meetup#50 - Ask the MuleSoft Ambassadors + CloudHub 2.0 Overvi...Jitendra Bafna
 
MuleSoft Surat Meetup#49 - Robotic Process Automation - Why, Where, When and ...
MuleSoft Surat Meetup#49 - Robotic Process Automation - Why, Where, When and ...MuleSoft Surat Meetup#49 - Robotic Process Automation - Why, Where, When and ...
MuleSoft Surat Meetup#49 - Robotic Process Automation - Why, Where, When and ...Jitendra Bafna
 
MuleSoft Surat Meetup#48 - Anypoint API Governance (RAML, OAS and Async API) ...
MuleSoft Surat Meetup#48 - Anypoint API Governance (RAML, OAS and Async API) ...MuleSoft Surat Meetup#48 - Anypoint API Governance (RAML, OAS and Async API) ...
MuleSoft Surat Meetup#48 - Anypoint API Governance (RAML, OAS and Async API) ...Jitendra Bafna
 
MuleSoft Surat Meetup#47 - Error Handling With MuleSoft
MuleSoft Surat Meetup#47 - Error Handling With MuleSoftMuleSoft Surat Meetup#47 - Error Handling With MuleSoft
MuleSoft Surat Meetup#47 - Error Handling With MuleSoftJitendra Bafna
 
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoftMuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoftJitendra Bafna
 
MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...
MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...
MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...Jitendra Bafna
 
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With RustMuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With RustJitendra Bafna
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Jitendra Bafna
 
MuleSoft Nashik Meetup#5 - JSON Logger and Externalize Logs
MuleSoft Nashik Meetup#5 - JSON Logger and Externalize LogsMuleSoft Nashik Meetup#5 - JSON Logger and Externalize Logs
MuleSoft Nashik Meetup#5 - JSON Logger and Externalize LogsJitendra Bafna
 
MuleSoft Surat Meetup#43 - Combine Service Mesh With Anypoint API Management ...
MuleSoft Surat Meetup#43 - Combine Service Mesh With Anypoint API Management ...MuleSoft Surat Meetup#43 - Combine Service Mesh With Anypoint API Management ...
MuleSoft Surat Meetup#43 - Combine Service Mesh With Anypoint API Management ...Jitendra Bafna
 
Engineering Student MuleSoft Meetup#5 - Error Handling With MuleSoft
Engineering Student MuleSoft Meetup#5 - Error Handling With MuleSoftEngineering Student MuleSoft Meetup#5 - Error Handling With MuleSoft
Engineering Student MuleSoft Meetup#5 - Error Handling With MuleSoftJitendra Bafna
 
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...Jitendra Bafna
 
MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...
MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...
MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...Jitendra Bafna
 

More from Jitendra Bafna (20)

MuleSoft Surat Meetup#55 - Unleash the power of Anypoint MQ
MuleSoft Surat Meetup#55 - Unleash the power of Anypoint MQMuleSoft Surat Meetup#55 - Unleash the power of Anypoint MQ
MuleSoft Surat Meetup#55 - Unleash the power of Anypoint MQ
 
MuleSoft Surat Meetup#54 - MuleSoft Automation
MuleSoft Surat Meetup#54 - MuleSoft AutomationMuleSoft Surat Meetup#54 - MuleSoft Automation
MuleSoft Surat Meetup#54 - MuleSoft Automation
 
MuleSoft Surat Meetup#53 - MuleSoft for Clinical Trial Modernization
MuleSoft Surat Meetup#53 - MuleSoft for Clinical Trial ModernizationMuleSoft Surat Meetup#53 - MuleSoft for Clinical Trial Modernization
MuleSoft Surat Meetup#53 - MuleSoft for Clinical Trial Modernization
 
MuleSoft Surat Meetup#52 - Flex Gateway (Port Based Routing V/S Path Based Ro...
MuleSoft Surat Meetup#52 - Flex Gateway (Port Based Routing V/S Path Based Ro...MuleSoft Surat Meetup#52 - Flex Gateway (Port Based Routing V/S Path Based Ro...
MuleSoft Surat Meetup#52 - Flex Gateway (Port Based Routing V/S Path Based Ro...
 
MuleSoft Surat Meetup#51 - API Monitoring - Through a New Lens
MuleSoft Surat Meetup#51 - API Monitoring - Through a New LensMuleSoft Surat Meetup#51 - API Monitoring - Through a New Lens
MuleSoft Surat Meetup#51 - API Monitoring - Through a New Lens
 
Engineering Student MuleSoft Meetup#7 - Leveraging MuleSoft Service in Salesf...
Engineering Student MuleSoft Meetup#7 - Leveraging MuleSoft Service in Salesf...Engineering Student MuleSoft Meetup#7 - Leveraging MuleSoft Service in Salesf...
Engineering Student MuleSoft Meetup#7 - Leveraging MuleSoft Service in Salesf...
 
MuleSoft Nashik Meetup#7 - Building FHIR applications in MongoDB using MuleSoft
MuleSoft Nashik Meetup#7 - Building FHIR applications in MongoDB using MuleSoftMuleSoft Nashik Meetup#7 - Building FHIR applications in MongoDB using MuleSoft
MuleSoft Nashik Meetup#7 - Building FHIR applications in MongoDB using MuleSoft
 
MuleSoft Surat Meetup#50 - Ask the MuleSoft Ambassadors + CloudHub 2.0 Overvi...
MuleSoft Surat Meetup#50 - Ask the MuleSoft Ambassadors + CloudHub 2.0 Overvi...MuleSoft Surat Meetup#50 - Ask the MuleSoft Ambassadors + CloudHub 2.0 Overvi...
MuleSoft Surat Meetup#50 - Ask the MuleSoft Ambassadors + CloudHub 2.0 Overvi...
 
MuleSoft Surat Meetup#49 - Robotic Process Automation - Why, Where, When and ...
MuleSoft Surat Meetup#49 - Robotic Process Automation - Why, Where, When and ...MuleSoft Surat Meetup#49 - Robotic Process Automation - Why, Where, When and ...
MuleSoft Surat Meetup#49 - Robotic Process Automation - Why, Where, When and ...
 
MuleSoft Surat Meetup#48 - Anypoint API Governance (RAML, OAS and Async API) ...
MuleSoft Surat Meetup#48 - Anypoint API Governance (RAML, OAS and Async API) ...MuleSoft Surat Meetup#48 - Anypoint API Governance (RAML, OAS and Async API) ...
MuleSoft Surat Meetup#48 - Anypoint API Governance (RAML, OAS and Async API) ...
 
MuleSoft Surat Meetup#47 - Error Handling With MuleSoft
MuleSoft Surat Meetup#47 - Error Handling With MuleSoftMuleSoft Surat Meetup#47 - Error Handling With MuleSoft
MuleSoft Surat Meetup#47 - Error Handling With MuleSoft
 
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoftMuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
MuleSoft Surat Meetup#46 - Deep Dive into MUnit With MuleSoft
 
MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...
MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...
MuleSoft Surat Meetup#45 - Anypoint Flex Gateway as a Kubernetes Ingress Cont...
 
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With RustMuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
MuleSoft Surat Meetup#44 - Anypoint Flex Gateway Custom Policies With Rust
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
 
MuleSoft Nashik Meetup#5 - JSON Logger and Externalize Logs
MuleSoft Nashik Meetup#5 - JSON Logger and Externalize LogsMuleSoft Nashik Meetup#5 - JSON Logger and Externalize Logs
MuleSoft Nashik Meetup#5 - JSON Logger and Externalize Logs
 
MuleSoft Surat Meetup#43 - Combine Service Mesh With Anypoint API Management ...
MuleSoft Surat Meetup#43 - Combine Service Mesh With Anypoint API Management ...MuleSoft Surat Meetup#43 - Combine Service Mesh With Anypoint API Management ...
MuleSoft Surat Meetup#43 - Combine Service Mesh With Anypoint API Management ...
 
Engineering Student MuleSoft Meetup#5 - Error Handling With MuleSoft
Engineering Student MuleSoft Meetup#5 - Error Handling With MuleSoftEngineering Student MuleSoft Meetup#5 - Error Handling With MuleSoft
Engineering Student MuleSoft Meetup#5 - Error Handling With MuleSoft
 
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
 
MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...
MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...
MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...
 

Recently uploaded

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Recently uploaded (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Integrating DROOLS

  • 1. Integrating DROOLS With Mule ESB JITENDRA BAFNA
  • 2. Integrating DROOLS With Mule ESB Overview DROOLS is Business Logic integration platform (BLiP). It is written in Java. It is an open source that is backed by RedHat and JBoss. It is Business Rules Management System (BRMS) solution. It provides a core Business Rules Engine (BRE), a web authoring and rules management application (Drools Workbench) and an Eclipse IDE plugin for core development. It is one of the best open source rule engine provides Complex Event Processing. Facts are stored in working memory (like in-memory database), Fact is piece of data, such as salary=3000 or in object oriented rules engine, it may be java object with properties. Rules are defined in a knowledge base.A rule consists of conditions (which typically depend on facts in the working memory) and actions which are executed when the conditions are true (similar to an "if-then" statement).
  • 3. Integrating DROOLS With Mule ESB Advantages Of DROOLS Rules Engine • Reusability: The rules are kept at some centralized location (separation of business logic from rest of system), it is easy to reuse Drools rules engine. • Flexibility: Changing the application or its model is not easy task but it is very easy to change the rules than Java code. • Redeploying: It is easy to redeploy modified rules without stopping or modifying the application logic. • Easier To Understand: It is easier to understand the rules for new developers that code written in java or any other languages. • You can avoid lot of if-else from your actual business logic by separating or implementing business rules separately. • Unifying: The Drools platform brings unification of rules and processes. It is easy to call rules from a process or vice versa. • Easy to implement Complex logic using Drools Rules Engine.
  • 4. Integrating DROOLS With Mule ESB Considerations for Using Drools Rule Engine • Let consider that DROOLS should be used when your Business Logic is very complex. Apart from complex business logic, you can use Drools in below situations • Application business logic often change. • Business Logic contains lot of If-Else statements. • The business logic is overly complex or time-consuming when defined procedurally. • The business logic needs to be maintained by people who don’t (or shouldn’t) have access to the application itself (to recompile/redeploy it). • Domain experts (or business analysts) are readily available, but are nontechnical.
  • 5. Integrating DROOLS With Mule ESB BusinessUseCase Todaywe will goingto implementbusinessuse case such as Life insurance policy,dependingon age and policytype,we will be providingpremium amount.Below is the logicsfor our businesscases • If age < 10 and policyType= "Policy1",then premiumAmount= 20000. • If age is between 10 and 40 and policyType= "Policy1", then premiumAmount= 30000. • If age > 40 and policyType= "Policy1", then premiumAmount= 40000. • If age < 10 and policyType= "Policy2",then premiumAmount =21000. • If age is between 10 and 40 and policyType= "Policy2", then premiumAmount =32000. • If age > 40 and policyType= "Policy2", then premiumAmount= 43000. Our flow willreceive belowJSON messageand we will use JSON data to pass throughour rules engine.
  • 6. Integrating DROOLS With Mule ESB Once JSON message passed through Rules Engine and our expected output is shown below.
  • 7. Integrating DROOLS With Mule ESB Implementing DROOLS With Mule ESB Now, we will walkthrough how to integrate the Mule ESB and Java rules engine namely DROOLS. Create Mule project and named the project droolsexample.xml and you can select Mule runtime 3.6 or higher. NamespaceAnd Schema First thing we need to add namespace and schema location to mule configuration file (e.g. droolsexample.xml).
  • 8. Integrating DROOLS With Mule ESB Initialize BPM Rules Add below tag in droolsdemo.xml and it will tell the mule flow there is some rules defined in your flow and it will start DROOL's working memory. Defining Mule Flow With DROOLS Rules We will be receiving the JSON message and it will be converted into Java object using JSONTo Object transformer. Our Java class for Insurance will look like this:
  • 9. Integrating DROOLS With Mule ESB package com.drools.example; publicclass Insurance { private String name; private int age; private String policyType; private int premiumAmount; publicString getName() { return name; } publicvoid setName(String name) { this.name=name; } publicint getAge() { return age; } publicvoid setAge(intage) { this.age=age; } publicString getPolicyType() { return policyType; } publicvoid setPolicyType(String policyType) { this.policyType=policyType; } publicint getPremiumAmount() { return premiumAmount; } publicvoid setPremiumAmount(intpremiumAmount) { this.premiumAmount=premiumAmount; } } Add file with .drl extension to your classpath (src/main/resources). This file will contains all rules in plaintext which can be easily modified and loaded at runtime if needed.
  • 10. Integrating DROOLS With Mule ESB1 package com.drools.example import org.mule.MessageExchangePattern; import com.drools.example.Insurance; global org.mule.module.bpm.MessageService mule; dialect "mvel" declare Insurance @role('event') end rule "Policy 1 And Infant" lock - on - active when $insurance: Insurance(age <10 && policyType =="Policy1") then modify($insurance) { setPremiumAmount(20000) } end rule "Policy 1 And Adult" lock - on - active when $insurance: Insurance((age >=10&&age <= 40) && policyType =="Policy1") then modify($insurance) { setPremiumAmount(30000) } end rule"Policy1 And Older" lock - on - active when $insurance: Insurance(age >40 && policyType =="Policy1") then modify($insurance) { setPremiumAmount(40000) } end rule "Policy 2 And Infant" lock - on - active when $insurance: Insurance(age <10 && policyType =="Policy2") then modify($insurance) { setPremiumAmount(21000) } end rule "Policy 2 And Adult" lock - on - active when $insurance: Insurance((age >=10&&age <= 40) && policyType =="Policy2") then modify($insurance) { setPremiumAmount(31000) } end rule"Policy2 And Older" lock - on - active when $insurance: Insurance(age >40 && policyType =="Policy2") then modify($insurance) { setPremiumAmount(41000) } end
  • 11. Integrating DROOLS With Mule ESB In rule file, we have defined import namespaces and packages statements.Then we create the Insurance object to be used by our rule engine and followed by some rules with conditions that explained earlier. Define Spring Beans You need to define spring beans in your configuration file (e.g. droolsexample.xml) as shown below
  • 12. Integrating DROOLS With Mule ESB Call Rule Definition in Mule Flow • Rule Definition can be call in Mule flow by defining below statement in configuration file (droolsexample.xml)
  • 13. Integrating DROOLS With Mule ESB Mule Flow [Code] <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:json="http://www.mulesoft.org/schema/mule/json"xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq"xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:bpm="http://www.mulesoft.org/schema/mule/bpm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/httphttp://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd http://www.mulesoft.org/schema/mule/ee/wmqhttp://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd http://www.mulesoft.org/schema/mule/bpmhttp://www.mulesoft.org/schema/mule/bpm/current/mule-bpm.xsd"> <bpm:drools/> <spring:beans> <spring:bean name="NoFactsBean" class="java.util.ArrayList"/> </spring:beans> <http:listener-configname="HTTP_Listener_Configuration" host="0.0.0.0" port="8081"doc:name="HTTPListenerConfiguration"/> <flow name="mule-proj-flowFlow"> <http:listenerconfig-ref="HTTP_Listener_Configuration" path="/drools"allowedMethods="POST" doc:name="HTTP"/> <wmq:object-to-message-transformer doc:name="Objectto Message"/> <json:json-to-object-transformer returnClass="com.drools.example.Insurance" doc:name="JSON to Object"/> <bpm:rules rulesDefinition="insuranceRules.drl"initialFacts-ref="NoFactsBean" doc:name="BPMRules"/> <set-payload value="#[payload.object]" doc:name="SetPayload"/> <json:object-to-json-transformer doc:name="Object toJSON"/> </flow> </mule>
  • 14. Integrating DROOLS With Mule ESB Testing We will use postman to test all the above scenarios and hopefully, we will get expected result back.
  • 15. Integrating DROOLS With Mule ESB Conclusion Mule provided easy steps to integrate with DROOLS and same is explained in above article. I hope you find this article interesting and provided required information to integrate DROOLS with Mule flow.