This series of posts will be about me getting to grips with JBoss Drools. The reasoning behind it is: SAP bought out my company's current rules engine and Drools is one alternative we will be looking into as soon as someone has the skills to get a proof of concept up.
Although there seems to be a fair amount of documentation, I always find it helps having walked through examples, which is what I am going to do here.Drools on first glance can be quite daunting, it is made up of :
Drools Expert (rule engine)
Being a developer this is where I will begin, the actual rules and implementation of them.
The other parts I'll get to later are:
Drools Guvnor (BRMS/BPMS)
Drools Flow (process/workflow)
Drools Fusion (event processing/temporal reasoning)
Drools Planner (automated planning)
So to begin.
For part 1, I just want to get my feet wet, I download only the Eclipse plugin and the binaries
Need to install the Eclipse plugin, used the update site. Unzip the binaries to a directory and withing the Eclipse plugin settings point to that directory.
The eclipse plugin will allow you to create a Drools Project and that includes the "Drools Library", but if you are using maven you need to point to the JBoss release repo for the Drools dependencies, The KnowledgeRuntimeLoggerFactory needs XStream which you can just get from the standard maven repo. Below is my POM:
To add a rule, on src/main/rules, Right click -> New -> Other... Drools/Rule Resource, be sure to choose the "individual rule". This leaves you with an empty drl file:
To understand and use the rule language, I read the Drools Documentation and the examples project.
What actually took me a little to grasp, was the basic syntax and how objects were handled in the rules and I did struggle to find anything that actually explains it simply so I will give it a shot.
A note on variable names.. they do not need to have the '$' but it was used in the example and without it quickly gets quite confusing.
Now to step through the parts of a rule:
The package, and import keyword are self explanatory, what happens after the when is not.
What is happening in "$vo : RoolVO( stringValue == "Learning to drool", $booleanVal : booleanValue )" broken down actually is:
stringValue == "Learning to drool" - This is a constraint that allows us to find all RoolVO objects known to the knowledge base that have the getStringValue() value equals to "Learning to drool". If there are multiple instances of RoolVO that comply we will run this rule more than once, these are also referred to as matched objects. You can also have multiple constraints separated by a ",".
$booleanVal : booleanValue - We are declaring a new local variable of type boolean called $booleanVal and gets it value from isBooleanValue.
$vo : RoolVO - We are declaring a new local variable of type RoolVO called $vo.
The next line:
"eval( $booleanVal )" - Evaluates the boolean variable, this needs to evaluate to true for the 'then' part of the rule to be called.
Then:
System.out.println( "First Rule" ); - Standard sys out.
$vo.setStringValue("Done."); - Sets the String value on the current RoolVO object that matched the constraints to Done.
The main classes / interfaces needed for a basic rule execution seem to be the following:
org.drools.KnowledgeBase and it's factory
org.drools.KnowledgeBaseFactory:
This is the repository of all the relevant knowledge definitions; it contains rules, processes, functions, type models.
org.drools.builder.KnowledgeBuilder and it's factory org.drools.builder.KnowledgeBuilderFactory:
Transforms / parses a source file (.drl, .xsl) into a KnowledgePackage that a KnowledgeBase can understand.
StatefulKnowledgeSession created by the KnowledgeBase .newStatefulKnowledgeSession();
This session is used to communicate with the actual rules engine.
To quote the drools JavaDocs:
StatefulKnowledgeSession is the most common way to interact with a rules engine. A StatefulKnowledgeSession allows the application to establish an iterative conversation with the engine, where the reasoning process may be triggered multiple times for the same set of data.
I wrote a simple test for the rule I described earlier.
To be honest, Drools is not nearly as intuitive as Quickrules was from what I have seen in this first task. However, in Part 2, I will start looking at using the rule flows, decision table functionality as well as the guided rules:
Those in partnership with the DSL (Domain Specific Language) construct hopefully do allow for more intuitive rules creation.
Subscribe to:
Post Comments (Atom)
Popular Posts
-
I have recently been slacking on content on my blog, between long stressful hours at work and to the wonderful toy that is an iPhone, I have...
-
I make no claim to be a "computer scientist" or a software "engineer", those titles alone can spark some debate, I regar...
-
I saw an article (well more of a rant) the other day, by Rob Williams Brain Drain in enterprise Dev . I have to say, I do agree with some o...
-
This series of posts will be about me getting to grips with JBoss Drools . The reasoning behind it is: SAP bought out my company's curre...
-
Update: Check out my updated re-certification on the new 2019 exam... here Let me start by saying, for this certification I studied and...
Promises to be an interesting series. I've wanted to look into Drools a couple of times, but never got to it. This was probably because it seemed to have a pretty steep learning curve and had too many bits and pieces.
ReplyDeleteHow will you handle migration from Quickrules, is there support for importing from other rules engines?
By the way I thought I'd just let you know, it doesn't look like your code snippets are showing up in the RSS feed. I can see the code in the XML but when rendered in HTML it's blank.
yeah, I felt exactly the same way, been wanting to start learning for ages, so I "forced" myself by publicly declaring it in a previous post. :)
ReplyDeleteThere isn't any I have seen, all the quickrules rule info is in a DB... will have to write a custom conversion kit.
Yeah, I know SyntaxHighlighter java script doesn't work in RSS, you know of something else I can use that will? (besides images).
Aye, migration from QuickRules will be painful. There are no standard structures for rule formats currently (JSR94 looks at execution as opposed to format - well at least the last time I looked at it). But Brian is volunteering to look at some kind of conversion tool.
ReplyDeleteI reckon we will end up migration rulesets across and doing a bit of rules refactoring at the same time.
Note that eval() is not indexed, so if isBooleanValue() is constant or only changed using a modify statement then you should test its value inside a conditional expression instead.
ReplyDeleteThanks, yeah I figured as much... this was also just to show another variable creation... but will keep it in mind.
ReplyDeleteThink of your "when" stuff as where clauses in a select statement.
ReplyDeleteSo RoolVO( stringValue == "Learning to drool" ) would be kind of like:
SELECT * FROM RoolVO WHERE RoolVO.stringValue = 'Learning to drool';
You'll find if you start thinking like this you'll start building more Drools-friendly rule constructs. I hope this helps.
Best,
Laird
Thanks for the comment Laird... that is actually a very nice way to think about it.
ReplyDeleteHi, i like your drools-blog :) Will there be a part 3 with jBPM or other?
ReplyDeleteWhat is your conclusion. Can Drools replace Yasu-Quickrules? How do you implement base rules in Drools?
very knowledgeable post.! Good to learn . It would be helpful for me if you could please provide example of : how to use Excel Spread sheet with drools, like dynamic calculations depending on the requirement..??
ReplyDeleteIf more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. Jammu Kashmir Ration Card Application
ReplyDeleteThanks for your post. I have read your blog its very attractive and impressive. I like it your blog. geometry dash
ReplyDeleteThank you for sharing! I hope you will continue to have great articles like this to share with everyone!
ReplyDeleteAs I read the blog I felt a tug on the heartstrings. it exhibits how much effort has been put into this.
ReplyDeleteFinal Year Project Domains for CSE
Spring Training in Chennai
Project Centers in Chennai for CSE
Spring Framework Corporate TRaining
Thanks for providing recent updates regarding the concern, I look forward to read more. cheap instagram likes paypal
ReplyDeleteAivivu vé máy bay giá rẻ
ReplyDeletesăn vé máy bay giá rẻ tết 2021
vé máy bay đi Mỹ khứ hồi
vé máy bay đi Pháp khứ hồi
giá vé máy bay từ tphcm đi hàn quốc
vé máy bay đi nhật bao nhiêu tiền
giá vé máy bay từ Hà Nội đi Anh
Aivivu chuyên vé máy bay, tham khảo
ReplyDeleteVe may bay di My
ve may bay my ve vietnam
vé máy bay từ Hà nội đi Los Angeles
từ canada về việt nam quá cảnh ở đâu
The content was very useful, we tend to are developing applications and helping business with high finish secured and interesting UI over the online and mobile apps get in touch for additional. kotlin application development company. You can email us at sales@appsquadz.com or call us at +91-9717270746
ReplyDeleteYeah bookmaking this wasn't a bad determination outstanding post!
ReplyDeleteMy web site; 강남안마
Order Valium Online from this website? Each medicine comes with high effects and a perfect range. Furthermore, this medication is containing a strong mind relaxing or calming. It gives instant results for treating multiples of psychological or physical stresses. Similarly, it clams the nerves and brain. In simple words, you can say that this drug manages by improving the action of specific neurotransmitters in the mind.
ReplyDeleteSitus judi online yang menyediakan poker online adalah website yang bergerak di bidang perjudian yang tidak perlu bertatap muka dengan orang lain, karena dijaman yang sudah canggih ini kita hanya cukup bermodalkan handphone android ataupun iOS/iphone maka kamu sudah bisa bermain dengan orang lain yang dimana bisa.
ReplyDeleteAre you looking for an order to buy cheap fake and real ID cards online? We are one of the best fake id websites. For more detail contact us.
ReplyDeleteBuy real and fake driver's licenses online at Passports service. We are a leading company that provides driver's licenses at the sale price.
ReplyDeleteWe are top suppliers of k2 paper and e liquids..... kindly contact us and get the best quality.
ReplyDeletehttps://rawgardenss.com/
ReplyDeletehttps://limestone420dispensary.com/
We are top providers of k2 paper and e liquids..... benevolently get in touch with us and get the best quality.
ReplyDeletehttps://www.bookmarking-maze.win/tiktok-ad-specs
https://mydocumentssuite.net/
ReplyDeleteHey there, it is great content. Looking forward to reading more articles on your blog. Thanks to the creator for writing the post. The better a monitor's refresh rate, the higher it should be. Higher refresh rates will typically result in much smoother-looking movement, which can be seen even in how fluidly the mouse cursor goes across the screen. If you want to check the monitor refresh rate then you should visit online refresh rate checker website.
ReplyDeleteEvery one deserves to be happy in their family or relationships, I was lucky enough to get my husband back , Doctor Robbinson helped me he is authentic , My Husband left me for 8 months and I was devastated and couldn't find any way out to get him back i tried all ways. At some point I was depressed, while i was reading through some post on the internet where people testified about how Dr Robbinson helped them Solve similar problems I contacted him and he never hesitated to help me as well, My husband is back home, my happiness is restored
ReplyDeleteText/call: +12267705795
Email: Drrobbinssonspiritualhome@gmail.com
đại lý Eva Air hcm
ReplyDeletechi phí đổi vé máy bay China Airlines
Japan Airlines được bao nhiêu kg hành lý
Look you spend a lot of time or effort to make this amazing one. I hope in future you share more good updates. Now it's time to avail Baby Liquid Soap for more information.
ReplyDeleteelazığ
ReplyDeleteerzincan
bayburt
tunceli
sakarya
4YD
448CF
ReplyDeleteBatman Evden Eve Nakliyat
Çerkezköy Cam Balkon
Yalova Lojistik
Samsun Evden Eve Nakliyat
Keçiören Parke Ustası
Siirt Şehir İçi Nakliyat
Bingöl Evden Eve Nakliyat
Kırıkkale Parça Eşya Taşıma
Maraş Parça Eşya Taşıma
4BBE6
ReplyDeleteLovely Coin Hangi Borsada
Parasız Görüntülü Sohbet
Btcst Coin Hangi Borsada
Kripto Para Nedir
Mexc Borsası Güvenilir mi
Instagram Beğeni Hilesi
Binance Nasıl Üye Olunur
Binance Referans Kodu
Omlira Coin Hangi Borsada
BAAF8
ReplyDeleteYoutube İzlenme Hilesi
Binance Madencilik Nasıl Yapılır
Kwai Beğeni Hilesi
Sohbet
Okex Borsası Güvenilir mi
Youtube Beğeni Hilesi
Facebook Grup Üyesi Hilesi
Gate io Borsası Güvenilir mi
Trovo Takipçi Hilesi
C4CEB
ReplyDeleteOnlyfans Beğeni Hilesi
Facebook Beğeni Hilesi
Coin Üretme Siteleri
Coin Madenciliği Siteleri
Linkedin Beğeni Hilesi
Binance Referans Kodu
Coin Kazma Siteleri
Snapchat Takipçi Hilesi
Binance'de Kaldıraç Var mı
B400B
ReplyDeletereferans kodu binance
kızlarla canlı sohbet
güvenilir kripto para siteleri
bybit
referans kimligi nedir
kucoin
bitexen
canlı sohbet ucretsiz
filtre kağıdı
FF8CB
ReplyDeletebkex
kripto telegram
kucoin
binance referans kod
kraken
bybit
binance
coinex
poloniex
24AB5
ReplyDeletemexc
bitget
coin nereden alınır
bybit
coinex
bitcoin nasıl üretilir
mobil proxy 4g
canlı sohbet ucretsiz
btcturk
DF1D7
ReplyDeleteokex
binance
bitcoin ne zaman çıktı
kraken
bitget
aax
mexc
en güvenilir kripto borsası
telegram türk kripto kanalları
4BF8E
ReplyDeletegörüntülü sanal şov
25D12
ReplyDeletewhatsapp güvenilir şov
47742
ReplyDeletewhatsapp görüntülü show
C5724951F0
ReplyDeletebayan azdırıcı damla
themra macun
kamagra
viagra
bufalo içecek
vigrande
yapay kızlık zarı
degra
cialis
F32A1EEDFA
ReplyDeleteşov
bufalo içecek
kaldırıcı
telegram görüntülü şov
görüntülü şov
bufalo çikolata
viga
ereksiyon hapı
stag
CE41FF89DF
ReplyDeletegörüntülü show
viga
sildegra
cam şov
görüntülü şov
bayan azdırıcı damla
skype show
viagra
cam show
43E9608D9B
ReplyDeleteskype show
canli web cam show
kamagra hap
whatsapp ücretli show
viagra
görüntülü şov whatsapp numarası
görüntülü show
sildegra
cialis