Sample Application Using Drools5 - drools

I am working on the Drools5.I am new to this Drools.I need a sample working example for this Drools.For this i have googled it alot but i did not find the correct one.If anyone has an idea can give me the reply.

Since I'm on the same boat as you are, I've searched for learning material quite a bit. Here are my resources:
http://www.jboss.org/drools For the general portal for the project.
Since this project has nicely modularized submodules, here they are:
Drools Guvnor for the Management Module that is used to manage packages of rules and POJOs with versions and also for deployment of snapshots for external usage.
Drools Expert for the expert systems core of the project. Here you can get a first look at how rule processing works under drools.
Drools jBPM5 for business workflow process modeling and integration.
Drools Fusion for Complex Event Processing (CEP) with which you can do all timeconstraint sorts of pattern matching you could think of (my favorite by the way ;).
Drools Planner for planning and business resource optimization.
For each of them, there is a complete and in my opinion high quality documentation out. In there you can really get a hands on an start digging in. You could also start working through one or the other of my personal list:
Getting started with drools fusion, by TheJavaDude
Creating Category, Package, Declarative Model, Rules And Snapshot In Drools Guvnor[Video]
Mark Proctors introduction to drools at FOSDEM[Video]
I hope this helps.
Greetings,
Kjellski

Related

Running Drools on GraalVM

We have a service that uses Drools quite heavily. Would like to improve the performance by running it on GraalVM.
Is it possible to run Drools on GraalVM without using Kogito?
Disclaimer: I'm one of the Drools developers
It's definitely possible, as you've already notice, we do indeed support native image compilation with our Quarkus backend, but it'll require you to write you some code, there's no such possibility in the current codebase.
Please note that only the executable model will be supported with the static component injection (the drools-core-static module in Kogito)
Is there a reason why you don't want to use Kogito though? We are really interested. Please join our community channels or the mailing list if you want to share your feedbacks, as SO is not the best platform for it.
Thanks for your support

It is possible to Integrate Activiti with Drools rule engin

I am working on a project and trying to evaluate Drools vs Activiti.
I know there is jBPM support but my client needs Activiti for managing the business flow and I need to use rule engin for evaluating some cases.
So is it possible to integrate drools and activity. Any pointer would help.
As I mention in the Gitter channel this is totally possible.
I will recommend you to do a small PoC (Proof of Concept) to really understand the details of it. People usually underestimate the complexity of a Rule Engine like Drools. Don't get me wrong, I love Drools, but I recommend you to check the docs and one of their books ;)
Check out the chapter in Tijs Rademaker's book "Activiti in Action". It describes the drools integration for version 5.x of Activiti very completely. The concepts are still valid for Activiti 6 as well.

Use drools as the underlying rule engine for a saas solution offering complex, editable rules

I'm in the process of designing a new saas solution that lets users configure relatively complex business rules in a web based environment. I'm leaning towards drools, but the web authoring application that ships with drools is way to complex and 'geeky' to show to the average user.
My idea is to create a simplified web authoring application that connects to drools, but having no experience with drools I have a hard time figuring out if this can be done. So that's my question:
Can this be done?
Secondly, do you think this is a good approach? (I know the 2nd question is a bit too generic for stackoverflow, but I'd appreciate it if you guys could share some quick pointers)
So you expect "relatively complex rules" but the existing authoring tool is too complex? The authoring of "complex rules" is a complex process, and no simple tool will be sufficient. (At least, I haven't seen or heard of one, so far.)
You don't need to "connect to Drools" for an authoring tool. All it has to do is to produce DRL (Drools' native rule language) text which is then compiled.
It would be a good approach, but only if you have an answer to the issue of how to create complexity with simple means.

how to evaluate if a project qualifies for or can be retrofitted with JBPM6

I had used JBPM 3.2 few years back as workflow engine. Now being part of a team were they had recently started a project, i need to evaluate if it can be improved/benefited by retrofitting JBPM 6 on it.
I am new to JBPM 6 so i read and researched to find road map for the list of changes,
http://www.jboss.org/jbpm/roadmap
whats new,
http://www.slideshare.net/krisverlaenen/2013-0611-whats-new-in-j-bpm6
did installation, demo and examples using,
http://docs.jboss.org/jbpm/v6.0/userguide/jBPMEclipseJBPM.html
however i am still coming up to speed in terms of what JBPM was and what it has become in these years and its capabilities. It would be helpful if someone can guide me in terms of what all things in a project scope make is qualify for JBPM 6.
thanks in advance,
There are a lot of reasons / advantages to using business processes (in general):
dynamic and flexible: extracting business logic in business process
allows you to evolve it or make it more flexible
higher-level: business analysts and end users could (possibly) understand and/or author business processes
monitoring and management: get an overview of all (current and historic) work
long-running and/or human tasks: some features are sometimes difficult to code but easier to express using specific business process constructs
performance: high throughput and scalability
tooling: a lot of out-of-the-box features and tools you can use
[note you definitely don't need to check all of these]
There's more, but you should make sure your benefits outweigh your initial learning curve / added complexity.

Maintaining drl (technical) rules in Drools Guvnor

I'm new to the world of business rules, but I think I've understood the concepts of Drools Expert and Drools Guvnor, yet I'm still a bit confused how/when/why exactly use Guvnor in comparison to Expert. And also, whether they rule each other out or are capable or even prefered to work side-by-side. Below are some highlighted topics that puzzle and a bit of explanation behind my concerns, mainly concentrating in application maintainability.
Does Guvnor have all the functionality that is available in Expert plus more?
I know that Guvnor is Business Rule Management System (BRMS) that takes control of storing(including versioning) the rules and exposing services to use of other apps. Guvnor contains UIs (text and graphical) for generating the rules and an engine for running them, so in this sense I guess it contains all functionality of the Expert system. Based on my requirements, I'm quite sure Guvnor is what I need, but do I need Drools Expert for anything after that?
Or in other words, does Drools Expert offer something that is not present in Guvnor?
Testing rules in Guvnor
Many tutorials on Drools I've seen start with TDD example where the rules are tested with simple jUnit tests. Once a rule is imported to Guvnor (or just generated there), is there any way to use/write unit tests for it?
Should the testing be done via exposed interfaces (REST) only?
If the users of the system are to develop their own rules, I don't expect them to write any tests. Mainly interested in 'core' rules and their maintainability here.
In case of 'core' rules, should they be stored in a version controlling system and imported to Guvnor on scheduled updates for the complete system? In this case the unit tests could be written for these rules and automatically executed as part of build cycle.
Thanks in advance.
Based on one of your questions, there's something I should clear up first. In essence:
Expert is a rules engine runtime.
Guvnor is a tool for writing and storing rules, which will subsequently be executed in Expert.
Guvnor doesn't provide a runtime for your rules, other than what is required for the test harnesses. You will always need Expert for your runtime environment. Guvnor enables you to manage the rules and store them. It also provides some handy GUI tools such as the guided editor and web decision tables. However, you can also edit rules in an IDE such as Eclipse and push them to Guvnor using the Guvnor WebDav Eclipse plugins.
Typically, you will have a Guvnor web application on one server and your application(s) on elsewhere. You can download the compiled rules from Guvnor into your application build, and deploy them with your application. Alternatively, you can define a URL resource in your code to create your knowledge base, pointing at the Guvnor package URL. In that case, your application can load the knowledge base on start-up and reload it at runtime.
For example the following code will download a package snapshot called "Approved" as a resource for building a knowledge base.
UrlResource urlResource =
(UrlResource) ResourceFactory.newUrlResource(
"http://my.guvnor.local/.../package/mypackage/Approved");
urlResource.setBasicAuthentication("enabled");
urlResource.setUsername("myusername");
urlResource.setPassword("mypassword");
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
builder.add(urlResource, resource.getType());
Edit - Take a look at KnowledgeAgent if you wish to have rules reloaded at runtime when they are changed in Guvnor.
My main reason for using Guvnor is to enable non-technical users to author rules using decision tables and DSL-based guided editors.
I like to edit technical rules in Eclipse, where I can easily write unit tests around them and evaluate that they are behaving as I expect. I find that much easier than the testing capabilities in Guvnor. And although Guvnor provides some version control, I much prefer Subversion/Git as version control for my technical rules.
I also write DSL in Eclipse, which I then deploy to Guvnor. This makes guided rules much simpler to work with for non-technical users.
Testing rules
With regards testing, there are a few options. There is testing functionality in Guvnor, which enables you to write expectations based on various inputs. However, I personally find that way too clunky and limiting to use. I far prefer to write tests in Java/JUnit.
First of all, you can write simple unit tests, which load one or two technical rules, written in DRL and evaluate that they are activating when you think they should, and generating inferred facts where appropriate.
For more complex testing, I write tests which create a knowledge base using a package in Guvnor, insert facts and fire rules, in order to evaluate that the package as a whole is working correctly, including those rules which have been built in guided editors or decision tables.
Other uses for Guvnor
It's worth noting that the Guvnor editor functionality is becoming much richer, and it is becoming an editor and repository for more than just rules. For instance, there is rich tooling for BPM processes, which should soon be better than what you can get in an IDE such as Eclipse.
Summary
If all your rules are written by yourself and other developers in DRL, then there is little benefit to using Guvnor. In fact I would find it a hindrance. However, if you wish to take advantage of the guided editors or decision tables, or you wish to have 'business' users manage some of the rules, then you should take a deeper look at Guvnor.