Google Summer of Code 2016: Drools & Minecraft

Another successful Google Summer of Code program took place this year. We worked together with Samuel Richardson from the USA to get the first integration between the Drools Engine and the popular game engine Minecraft. The scope of the project was to experiment how Drools can be used to declaratively define a game’s logic. I initially thought about modelling point & click games such as Escape The Room, Monkey Island, Maniac Mansion, etc but after looking at how to work with Minecraft I’ve opened the concept to wider game definitions. 
We worked with Sam into creating a generic game engine that will take the Rules Definitions and drive the game (the Minecraft Mods) . Sam created a couple of Minecraft MODs that provides a scenario for the game which interacts and delegate to Drools the game’s logic.
You can find the work for the Drools Game Engine here:
These two games are using the rules described here:
and here:
We spent a lot of time in trying to get the separation right, so now you can consume the game server itself indepentendly of the UI. This opens up the doors so you can use the engine withoug Minecraft. For that reason we have created also a set of services that exposes the Game Engine via rest in case that you want to interact with it remotely.
You can take a look at the main GameSession interface which is in charge of defining how to create new game sessions and enables the UI to register callbacks so actions can be executed when the logic of the game says so.
Because of this separation you will see that each game has its own test suite where both, the Rules and the GameSession API is tested to make sure that new games can be created and the rules are behaving as expected.
There is a lot of things to improve still, both in the Game Engine and in the MODs, so feel free to get in touch with us if you want to participate on the project. Hopefully we can build enough features to include it in the Drools Project.

#Drools & #jBPM @ #JBCNConf 2016 (Barcelona, June)

Great news! Once again the amazing and flamboyant leaders of the Java User Group from Barcelona manage to put together their anual conference JBCNConf. And, of course, Drools & jBPM will be there. Take a look at their website for more information about the talks and speakers, and if you are close enough to Barcelona I hope to see you all there.
This year I will be doing a Drools Workshop there (Thursday, first day of the conference), hoping to introduce people to Drools in a very hands on session. So if you are looking to start using Drools straight away, this is a great opportunity to do so. If you are a more advanced user and wants to bring your examples or issues to the workshop you are more than welcome. I will be sharing the projects that I will be using on the workshop a couple of weeks before the event so  can take a look and bring more questions to the session. It is also probable that I will be bringing with me freshly printed copies of the new Mastering Drools book, so you might be able to get some copies for free 🙂
Maciej Swiderski will be covering the jBPM and Knowledge Driven Microservices this year. I totally recommend this talk to anyone interested in how to improve your micro services by adopting tools to formalise and automate domain specific knowledge.
Finally, this year Maciej and I will be given the closing talk of the conference titled : The Open Source Way were we will be sharing with the audience the main benefits of getting involved with the open source community & projects but most importantly we will be sharing how to do achieve that. If you are already an Open Source project contributor and you plan to attend to the conference, get in touch!
Stay tuned for more news, and get in touch if you want to hang around with us before and after the conference!

Oficial Wildfly Swarm #Drools Fraction

Oficial what? Long title for a quite small but useful contribution. Wildfly Swarm allows us to create rather small and self contained application including just what we need from the Wildfly Application Server. On this post we will be looking at the Drools Fraction provided to work with Wildfly Swarm. The main idea behind this fraction is to provide a quick way to bundle the Drools Server among with your own services inside a jar file that you can run anywhere.

Microservices World

Nowadays, while micro services are a trending topic we need to make sure that we can bundle our services as decoupled from other software as possible. For such a task, we can use Wildfly Swarm that allows us to create our services using a set of fractions instead of a whole JEE container. It also saves us a lot of time by allowing us to run our application without the need of downloading or installing a JEE container. With Swarm we will be able to just run java -jar <our services.jar> and we are ready to go.
In the particular case of Drools, the project provides a Web Application called Kie-Server (Drools Server) which offers a set of REST/SOAP/JMS endpoints to use as a service. You can load your domain specific rules inside this server and create new containers to use your different set of rules. But again, if we want to use it, we will need to worry about how to install it in Tomcat, Wildfly, Jetty, WebSphere, WebLogic, or any other Servlet Container. Each of these containers represent a different challenge while it comes to configurations, so instead of that we can start using the Wildfly Swarm Drools Fraction, which basically enables the Drools Server inside your Wildfly Swarm application. In a way you are bundling the Drools Server with your own custom services. By doing this, you can start the Drools Server by doing java -jar <your.jar> and you ready to go.
Imagine the other situation of dealing with several instances of Servlet Containers and deploying the WAR file to each of those containers. It gets worst if those containers are not all the same “brand” and version.
So let’s take a quick look at an example of how you can get started using the Wildfly Swarm Drools Fraction.


I recommend you to take a look at the Wildfly Swarm Documentation first, to get you started on using Wildfly Swarm. If you know the basics, then you can include the Drools Fraction.
I’ve created an example using this fraction here:
The main goal of this example is to show how simple is to get you started with the Drools Fraction, and for that reason I’m not including any other service in this project. You are not restricted by that, and you can expose your own endpoints.
Notice in the pom.xml file two things:
  1. The Drools Server Fraction: By adding this dependency, the fraction is going to be activated while Wildfly Swarm bootstrap.
  2. The wildfly-swarm plugin: Notice in the plugin configuration that we are pointing to the App class which basically just start the container. (This can be avoided, but I wanted to show that if you want to start your own services or do your own deployments you can do that inside that class)
If you compile and package this project by doing mvn clean install, you will find in the target/ directory a file called:
drools-server-swarm-1.0-SNAPSHOT-swarm.jar which you can start by doing
<br /><br />java -jar&nbsp;drools-server-swarm-1.0-SNAPSHOT-swarm.jar<br /><br />
For this example, we will include one more flag when we start our project to make sure that our Drools Server can resolve the artefacts that I’m going to use later on, so it will be like this:
<br /><br />java -Dkie.maven.settings.custom=../src/main/resources/settings.xml&nbsp;-jar drools-server-swarm-1.0-SNAPSHOT-swarm.jar<br /><br />
By adding the “kie.maven.setting.custom” flag here we are letting the Drools Server know that we had configured an external maven repository to be used to resolve our artefacts. You can find the custom settings.xml file here.
Once you start this project and everything boots up (less than 2 seconds to start wildfly-swarm core + less than 14 to boot up the drools server) you are ready to start creating your KIE Containers with your domain specific rules.
You can find the output of running this app here. Notice the binding address for the http port:
WFLYUT0006: Undertow HTTP listener default listening on [0:0:0:0:0:0:0:0]:8083
Now you can start sending requests to http://localhost:8083/drools to interact with the server.
I’ve included in this project also a Chrome’s Postman project for you to test some very simple request like:
  • Getting All the registered Containers -> GET http://localhost:8083/drools/server/containers
  • Creating a new container – > PUT http://localhost:8083/drools/server/containers/sample
  • Sending some commands like Insert Fact + Fire All Rules -> POST http://localhost:8083/drools/server/containers/instances/sample
You can import this file to Postman and fire the requests against your newly created Drools Server. Besides knowing to which URLs to PUT,POST or GET data, you also need to know about the required headers and Authentication details:
Authentication -> Basic
User: kieserver
Password: kieserver1!
Finally, you can find the source code of the Fraction here:
There are tons of things that can be improved, helpers to be provided, bugs to be fixed, so if you are up to the task, get in touch and let’s the Drools fraction better for everyone.

Summing up

While I’m still writing the documentation for this fraction, you can start using it right away. Remember that the main goal of these Wildfly Swarm extensions is to make your life easier and save you some time when  you need to get something like the Drools Server in a small bundle and isolated package that doesn’t require a server to be installed and configured.
If you have any questions about the Drools Fraction don’t hesitate to write a comment here.

Mastering #Drools 6 book is out!

Hi everyone, just a quick post to share the good news! The book is out and ready to ship! You can buy it from Packt or from Amazon directly. I’m happy to announce also that we are going to be presenting the book next week in Denmark, with the local JBug: if you are around or know someone that might be interested in attending please let them know!
Mastering Drools 6
The book covers a wide range of topics from the basic ones including how to set up your environment and how to write simple rules, to more advanced topics such as Complex Event Processing and the core of the Rule Engine, the PHREAK algorithm.

High Availability Drools Stateless Service in Openshift Origin

openshift-origin-logoHi everyone! On this blog post I wanted to cover a simple example showing how easy it is to scale our Drools Stateless services by using Openshift 3 (Docker and Kubernetes). I will be showing how we can scale our service by provisioning new instances on demand and how these instances are load balanced by Kubernetes using a round robin strategy.

Our Drools Stateless Service

First of all we need a stateless Kie Session to play around with. In these simple example I’ve created a food recommendation service to demonstrate what kind of scenarios you can build up using this approach. All the source code can be found inside the Drools Workshop repository hosted on github:
In this project you will find 4 modules:
  • drools-food-model: our business model including the domain classes, such as Ingredient, Sandwich, Salad, etc
  • drools-food-kjar: our business knowledge, here we have our set of rules to describe how the food recommendations will be done.
  • drools-food-services: using wildfly swarm I’m exposing a domain specific service encapsulating the rule engine. Here a set of rest services is exposed so our clients can interact.
  • drools-controller: by using the Kubernetes Java API we can programatically provision new instances of our Food Recommendation Service on demand to the Openshift environment.
Our unit of work will be the Drools-Food-Services project which expose the REST endpoints to interact with our stateless sessions.
Also notice that there is another Service that gives us very basic information about where our Service is running:
We will call this service to know exactly which instance of the service is answering our clients later on.
The rules for this example are simple and not doing much, if you are looking to learn Drools, I recommend you to create more meaning full rules and share it with me so we can improve the example 😉 You can take a look at the rules here:
As you might expect: Sandwiches for boys and Salads for girls 🙂
One last important thing about our service that is important for you to see is how the rules are being picked up by the Service Endpoint. I’m using the Drools CDI extension to @Inject a KieContainer which is resolved using the KIE-CI module, explained in some of my previous posts.
We will bundle this project into a Docker Image that can be started as many times as we want/need. If you have a Docker client installed in your local environment you can start this food recommendation service by looking at the salaboy/drools-food-services image which is hosted in
By starting the Docker image without even knowing what is running inside we immediately notice the following advantages:
  • We don’t need to install Java or any other tool besides Docker
  • We don’t need to configure anything to run our Rest Service
  • We don’t even need to build anything locally due the fact that the image is hosted in
  • We can run on top of any operating system
At the same time we get notice the following disadvantages:
  • We need to know in which IP and Port our service is exposed by Docker
  • If we run more than one image we need to keep track of all the IPs and Ports and notify to all our clients about those
  • There is no built in way of load balance between different instances of the same docker image instance
For solving these disadvantages Openshift, and more specifically, Kubernetes to our rescue!

Provisioning our Service inside Openshift

As I mention before, if we just start creating new Docker Image instances of our service we soon find out that our clients will need to know about how many instances do we have running and how to contact each of them. This is obviously no good, and for that reason we need an intermediate layer to deal with this problem. Kubernetes provides us with this layer of abstraction and provisioning, which allows us to create multiple instances of our PODs (abstraction on top of the docker image) and configure to it Replication Controllers and Services.
The concept of Replication Controller provides a way to define how many instances should be running our our service at a given time. Replication controllers are in charge of guarantee that if we need at least 3 instances running, those instances are running all the time. If one of these instances died, the replication controller will automatically spawn one for us.
Services in Kubernetes solve the problem of knowing all and every Docker instance details.  Services allows us to provide a Facade for our clients to use to interact with our instances of our Pods. The Service layer also allows us to define a strategy (called session affinity) to define how to load balance our Pod instances behind the service. There are to built in strategies: ClientIP and Round Robin.
So we need to things now, we need an installation of Openshift Origin (v3) and our project Drools Controller which will interact with the Kubernetes REST endpoints to provision our Pods, Replicator Controllers and Services.
For the Openshift installation, I recommend you to follow the steps described here:
I’m running here in my laptop the Vagrant option (second option) described in the previous link.
Finally, an ultra simple example can be found of how to use the Kubernetes API to provision in this case our drools-food-services into Openshift.
Notice that we are defining everything at runtime, which is really cool, because we can start from scratch or modify existing Services, Replication Controllers and Pods.
You can take a look at the drools-controller project. which shows how we can create a Replication Controller which points to our Docker image and defines 1 replica (one replica by default is created).
If you log in into the Openshift Console you will be able to see the newly created service with the Replication Controller and just one replica of our Pod. By using the UI (or the APIs, changing the Main class) we can provision more replicas, as many as we need. The Kubernetes Service will make sure to load balance between the different pod instances.
Voila! Our Services Replicas are up and running!
Voila! Our Services Replicas are up and running!
Now if you access the NodeStat service by doing a GET to the mapped Kubernetes Service Port you will get the Pod that is answering you that request. If you execute the request multiple times you should be able to see that the Round Robin strategy is kicking in.
wget http://localhost:9999/api/node {“node“:”drools-controller-8tmby“,”version”:”version 1″}
wget http://localhost:9999/api/node {“node“:”drools-controller-k9gym“,”version”:”version 1″}
wget http://localhost:9999/api/node {“node“:”drools-controller-pzqlu“,”version”:”version 1″}
wget http://localhost:9999/api/node {“node“:”drools-controller-8tmby“,”version”:”version 1″}
In the same way you can interact with the Statless Sessions in each of these 3 Pods. In such case, you don’t really need to know which Pod is answering your request, you just need to get the job done by any of them.

Summing up

By leveraging the Openshift origin infrastructure we manage to simplify our architecture by not reinventing mechanisms that already exists in tools such as Kubernetes & Docker. On following posts I will be writing about some other nice advantages of using this infrastructure such as roll ups to upgrade the version of our services, adding security and Api Management to the mix.
If you have questions about this approach please share your thoughts.

Drools @ JUG Cork, Ireland (2nd March 2016)

Hi all, I’m creating this blog post to share with you all that I’m doing a presentation in the Java User Group at Cork, Ireland
For more information about the meet up go here:
The session is titled “Go back home knowing how to use Drools 6 in your own projects” and it will be focused on the basics to get you started using Drools and the common pitfalls that new developers might find when using Drools. We will also quickly cover some common architectural patterns of using Drools and how it can be integrated into your existing applications. 
If you are planning to attend please share this blog post with your friend and post a message here or in the meet up page with the topics that you would like to see during the presentation. As usual, I’m pretty open to cover what the audience consider more important. 
I will be back with more information more close to the meet up date. 

Drools Workshops Chile/Argentina (Nov/15)

Hi Everyone, I’m going to South America for two weeks in November and I’m planning to deliver two community workshops around Drools and jBPM. The workshops will be mostly focused on Drools (time restrictions) but I will try to include brief intro about jBPM as well.
I’ve drafted an initial agenda, that might change based on the feedback from people that is planning to attend. Feel free to drop me a comment if you want to see something in particular. I will do my best to accommodate more topics based on the amount of time that we have available.
Click here for the Spanish Version of this post.


Initially these are the dates and cities for the Workshops:
If you are interest in attending please get in touch with me or the organisers in each of the cities and if you can help me to spread the word about these workshops I will appreciate it. The more community members that we can gather the better the workshops are, mostly because we can all share experiences, headaches and future roadmaps.

Suggested Agenda

Here is my initial draft for the Agenda (this might change based on feedback)
1) Intro to Drools
2) Creating a Simple Project
3) Intro to the new KIE Server, how to integrate our apps with Drools
4) Overview about the KIE Workbench
5) Roadmap (7.x and future)
6) Drools + Microservices (Docker/Kubernetes)
7) Community Stories (here I will encourage the participants to share their use cases, if you are interested in giving a very short presentation about what your project is about please let me know, so we can create a list)
Feel free to drop me a message if you want to add something to it. The idea is to work with our laptops and get an application working by the end of the day. If we all work together during the Workshop we will be able to make it more interactive and share more experiences and doubts. I would like to avoid giving too much presentations, so I will try to keep these meet ups as hands on as possible.

Workshop Chile

I will be updating this post with more news every week so stay tuned!

Google Summer of Code 2015: jBPM Mobile (MGTW)

I would like to share with all you guys the success story from the Google Summer of Code 2015 program in collaboration with the jBPM project. This year Rodrigo Garcete from (Ciudad del Este) Paraguay, who this year was in charge of upgrading the jBPM Mobile implementation created using MGWT. This application is a proof of concept showing a fully functional mobile client that can deploy KIE Jars to the execution runtime and then start processes and tasks.
I personally had a great experience interacting with Rodrigo during the program and I do believe that the jBPM community gained a very valuable community member. Here you can find Rodrigo’s fork containing the latest version of the code:
Keep reading to see what Rodrigo’s experience was and at the end a short video showing the app in action. 

Rodrigo about the GSoC Program

Hi everyone
I am very grateful to the GsoC2015 program, for giving me the opportunity to participate this year, it was my first experience working with an open source community.
Also, I want to thank the community, specifically my mentor Mauricio Salatino (salaboy), for the trust you have placed in me.
The project to which work closely with my mentor salaboy this summer called jBPM Console NG Mobile, as its name implies, the aim of the project was to  adapt the jBPM Console NG application and make it available in the mobile world.
The technology stack that we used consist of MGWT,  UberfireErrai and jBPM.
It is important to mention that the project was already running, but with an old version of MGWT (1.2) and it was also using old services from the jBPM infrastructure.
First thing I did was to migrate all components to use the latest MGWT  version (2.0).
Then I had to modify the API calls to backend services, these changed a lot in version 6.4.0-SNAPSHOT.
The work was not easy .. but it wasnt  impossible, whenever I hit some problems, salaboy help me, explaining, and answering any questions I had, guiding me towards the right path.
After the first evaluation (mid term), all the upgrade was completed and we started looking into adding some new features and improvements. Little by little I was learning the internals of project, everything started to make more sense, and I was getting faster in getting things up and running.
In the final stage, we added new features such as the Deployment screen, the ability to start a process with variables and also completing tasks with simple variables.
From my side, I can say that I learned a lot, the experience was very rewarding, and I would like to encourage  other students in the world to participate in this program. You will learn a lot by working on any open source project.
My  idea is to continue collaborating with the project, keep improving it, adding new features, etc., 
To close this post, I uploaded a video showing the features and improvements that we have had done with salaboy during the program.

Summing up

This was a great year for the program and in my opinion the end results were exactly what the program was designed for:
  • Students getting involved in open source communities
  • Contributing valuable code and research
  • The Student learned real life tools and technologies
Hopefully next year one or more students can participate in the program and contribute to jBPM and Drools!

jBPM accepted on Google Summer of Code 2014!

I’m thrilled to share with the whole Drools & jBPM community that once again a student has being accepted in the Google Summer Of Code Program to work in the projects for the Summer. This year Google will be funding  Nicolas Gomes (from Argentina) to work on the jBPM project. Nicolas task will be to work towards the integration of the KIE Workbench with a Content Management System such as Magnolia.
GSoC 2013
The integration will involve the backend services and front end screens to work with documents from end to end.
Here you can find all the accepted projects this year (2014):
Nicolas has also started a blog where he will sharing the integration progress,
You can also follow him on twitter:
twitter: @nicolasegomez
As I will be mentoring the work, I will be also sharing some updates and videos about how the work is being done. So stay tuned and feel free to leave comments in Nicolas’ blog regarding his proposals for the work that needs to be done. If you are looking to do something similar please get in touch with Nicolas or with myself so we can coordinate the work.

Results from the Drools & jBPM Workshop @ Bcn (10th Dec)

I’m quite happy to say that the Barcelona Workshop was a complete success. Once again I would like to thanks the @BarcelonaJug for all the effort that they put into organise these meetups. This post is to share some pics and some overall comments about the event.

The Barcelona Java User Group

Find here some pics about the group, with almost 30 attendees interested in Drools & jBPM the workshop was a success, all of the attendees manage to run & play with KIE Workbench:

If you are working in a company based in Barcelona, I strongly suggest you to support your local JUG. This will benefit you to build up your knowledge, bring expert people from abroad and share the knowledge that is being produced locally by the other members of the group.

Do the Workshop on your own Laptop

Once again I’m sharing the files that we distributed on the workshop so you can try it on your own environment. If you are interested in building all the projects from the source code let me know I can help you out to set up the environment to get you started.

Feedback from the Community

As usual, when we present the community projects, we gather a lot of feedback from the people that is testing the tool and we take notes to improve the user experience. I’ve noticed from this last meet up that there is a lot of interest in knowing about the project internals. For that reason I’ve proposed another meet up probably for the beginning of February to cover Drools & jBPM from the framework perspective without showing the tooling. I do believe that knowing the framework internals is something interesting for most of developers, but at the same time I feel that knowing about the tools will give them a more higher level understand about what’s the main purpose of these frameworks and tools. You can obviously target to a wider audience with the UI provided by the KIE Workbench, showing with this tools how you can help the whole company spectrum with a knowledge driven solution.
As a reminder, all the software that we had shown in the meet up was built using the master branch of the source code repositories, so you can expect some issues that are being solved. The main idea of showing the community builds is to encourage people to participate into this community projects.
Feel free to write some comments into this blog post with some suggestions about what kind of topics you would like to see in an internal talk about Drools & jBPM. I usually like to talk about both frameworks because they shared a lot of common topics that needs to be discussed under the same context.