Sunday, May 29, 2011

Emergency Services - jBPM5 and Drools Demo App

I'm proud to release the second version of the Emergency Services jBPM5 and Drools demo application. We (@ilesteban and I @salaboy) spend a fair amount of time creating the second version that helps us to show some best practices about how to build applications on top of the Drools & jBPM5 platform. We are advertising this application as a jBPM5 and Drools blueprint that shows one of the possible architectures that can be used to build robust applications mixing Business Processes, Business Rules and Complex Event Processing. I'm also happy to announce that a new dev has join us (@calcacuervo) in this effort to share best practices and an end to end application that shows. We are waiting for your feedback and contributions, feel free to join us there are tons of things to do!

This version was already presented in a couple of events like: JUDCon and a some bootcamps in the US, where we receive awesome feedback and that really motivate us to keep going and improving what we got. We were very happy to see that some Red Hat's solution architects were using the application to show their customers how the jBPM5 and Drools project can be used to build smarter applications.

New Features / Improvements

The focus of this second version was a complete refactoring to the old code base that was messy and cannot be reused, improved or extended. We decouple the monolithic project into separated modules that interacts using asynchronous messages (HornetQ/JMS).
Taking advantage of these decouple architecture we also include Drools Grid that enables the application to run in a distributed cluster of virtual/physical machines. The application now has the availability of create knowledge based services in different remote nodes being able to distribute the load between different machines.
The use case that is currently supported it's the same as the one implemented in the version 1 of the application. But the current implementation allows us to easily extend and add more use cases that involve collaboration between different entities inside the city. The new set of decoupled components have a well defined scope and responsibility that it's described in the following section. We also create a new Emergency Dashboard to show in real time what's happening in a specific emergency and how many emergencies we are handling in a specific moment in time.

Finally we open a wiki that can be found here, to help the new comers that are interested to play with the application to download it and play with it.

Application Structure / Modules

The current version of the application contains the following modules:

  • emergency-service-model

  • emergency-service-core

  • emergency-service-world-ui-slick

  • emergency-service-tasklists-ui-swing

  • emergency-service-tasklist-ui-web

  • emergency-service-sensor

In order to understand how the application works and how all these modules interacts we need to understand the scope and responsibility of each of them. The following sections explains the scope and how the functionality was separated in order to support the use cases.

Emergency Service Model

This simple Java (JAR) project includes all the Domain POJOs definitions. Inside this project we define all the classes that represent the data structures that will be used by the rest of the modules and are related to our domain. In this case because we are modeling and Emergency Services Company like 911 we will have some POJOS like: Emergency, Call, Vehicle, Ambulance, etc. You will find also a couple of utility classes and Drools/JBPM5 artifacts that were included here for simplicity. This JAR package needs to be shared by all the different processes that are created for this application to work. Because the new design was conceived for a distributed environment we need to provide a package (or a set of packages) that contains all the domain specific dependencies that will be needed by the different runtimes that will be dynamically spawned by the application.

Emergency Service Core

The core project now contains a set of services that encapsulate the logic required by the application. The current defined services are all knowledge based services. This means that all of them are using rules, processes and events. But the main idea is to be able to plug any type of service. For future release will make sense to split this module to be able to manage one or a group of services together. You can browse the currently defined services here:

You will notice that we have a service that it's in charge of dynamically create new services instances based on the situation that we are trying to solve, allowing us to plug new procedures without the need of modifying how the procedures are started.

This project is also containing the processes and rules assets inside the src/main/resources directory. For future versions of the project the assets should be placed inside the Knowledge Repository (Guvnor) and use a knowledge agent to retrieve these assets when they are needed.

Emergency Service World UI

Right now the application has only one implementation of the World UI component. We are using a library called slick: The main responsibility of this module is to show what it's happening in the city. In real application we don't have a representation of what's happening, but for this demo we want to show and let you interact with the real world to simulate different situations. It's important for us to show what it's happening, but you need to remember that from inside the company, where all the employees are working, they will receive only notifications about the external world.

Emergency Service Task Lists UI

The application right now provides two different implementations for the task lists user interfaces. Remember that the Task Lists UIs will represent the software that will be used by the companies employees. The tasks will be created by business processes and also business rules when are required. The users will automatically receive the created tasks in their task lists. Both implementations are using a project called smart-tasks to improve how the task lists and task form are defined and configured. The web version uses some more advanced features of smart tasks to demonstrate how the project can be used to quickly build task list oriented front ends to interact with the human activities created by our business knowledge. You can find more about the smart tasks project here:

Emergency Service Sensor

This module contains the different adaptors to support external sources of events that can be used to represent real life information that it's coming into our system. The first version of this application was working only with a Nintentdo Wii Remote Control (WiiMote), but the new version supports also the accelerometer of the IPhone. You should only install a free application called AccSim in your phone to send the accelerometer events. We use these accelerometers to simulate the patients heart beats when we have a heart attack situation.
We are thinking to provide an extra module to support Android devices as well, but it's still under development at the moment.


The roadmap at this point for V3 is to improve the way to execute and extend the application. We will fight to include more complex use cases using the current architecture. We will be targeting the V3 for Rules Fest (October 24-27), and this version will include more dynamic mechanisms to discover the procedures that needs to be executed in order to solve more complex scenarios. For that reason we will be implementing multiple procedures that involves different entities like the police department and the fire department. The real fun begins when we want to solve situations that involves more than one entity to be coordinated. We are looking forward to implement some graphical aids to be able to show alerts inside the map in real time as they happen.

One minor refactor that we will be doing is creating a separate module for the Real Time Dashboard project, because right now it is included inside the Task Lists UI Swing application, but it doesn't belong there.

I will be writing a more detailed post about the architecture of the application and logic that it's being executed by each service inside the application soon. Also a detailed roadmap will be created based on the feedback. Please don't post commands about THE MONSTER! we will be adding that use case as well :)

If you want to see something in particular implemented here, please write a comment.


We want to notify to all the people that its downloading the application and want to start playing with it a couple of things:

  1. We are not creating tags/branches to keep the stable versions. We don't have a tag/branch for Version 1 and Version 2. We strongly believe that there are a lot of things that needs to be improved in order to create what we think is a stable version. If you check out the current code please remember that you are getting the latest code that it's under continuous refactoring and improvement. Write us if you are having troubles, we will be here to help you.

  2. If you want to play with the application take a look at the wiki for the documentation and how to's to set up and run the application in different operating systems. If you have troubles, please report them sending me an email: (salaboy AT gmail DOT com - esteban DOT aliverti AT gmail DOT com) or add a comment to the project. If you solve a problem related with your platform, please send us the information and we will include that in the wiki pages.

  3. We are mentoring and helping people to get involved. If you want to show or demonstrate how these projects like Drools, jBPM, HornetQ and Inifinispan works and how they can be used in your applications please contribute with this project. We build a generic architecture that can be adapted to almost every application domain. Everyone can benefit for the features that we are adding here in this application. For creating your own domain specific application then you can copy and paste the mechanisms and adapt the processes, rules and events sources to work for your domain.
Original Post:

Friday, May 27, 2011

Damian Conway - Programming in Latin

Just met Damian Conway at "Big Tech Day". Really good talk. Damian wrote many excellent Perl books that I loved, back when I was a perl developer - so was great to meet him in real life and thank him.

He just gave a great talk on dead languages, showing how to programming in Postscript finishing in writting a complete executable programming language in Latin. Great stuff, had everyone laughing throughout.
Lingua::Romana::Perligata -- Perl for the XXI-imum Century

Who can figure out what this does?
       #! /usr/local/bin/perl -w

use Lingua::Romana::Perligata;

maximum inquementum tum biguttam egresso scribe.
meo maximo vestibulo perlegamentum da.
da duo tum maximum conscribementa meis listis.

dum listis decapitamentum damentum nexto
fac sic
nextum tum novumversum scribe egresso.
lista sic hoc recidementum nextum cis vannementa da listis.


Releases: Drools (Expert, Fusion, Planner) 5.2.0.CR1, Guvnor 5.2.0.CR1 and jbpm 5.1.0.CR1

We're happy to announce the release of Drools 5.2.0.CR1 and jBPM 5.1.0.CR1.



    JBoss Day at JAXconf - An evening with Drools

    This year JAXconf will hold a special JBoss Day at it’s upcoming conference in San Jose, on Tuesday June 21. JBoss Day will be held at the San Jose Convention Center starting at 2:00 PM and ending at 10:00 PM (PT).

    This year's sessions:
    - "The Mobile Web Revealed For The Java Developer" (Jay Balunas)
    - "7 reasons to love JBoss AS 7" (Dan Allen)
    - "JBoss Drools and Drools Fusion (CEP)" (Tihomir Surdilovic)
    - "Bring your own laptop lab - Apply JBoss Drools and CEP to your application" (Tihomir Surdilovic)

    To register and get more information go to the event page.
    Registration for JBoss Day is free!

    Thursday, May 26, 2011

    Using jBPM domain-specific service nodes in Oryx designer

    jBPM allows users to extend the default process constructs with domain-specific extensions. These extensions, also called domain-specific service nodes, simplify development in a particular application domain in that they are:
    1. domain-specific
    2. declarative (what, not how)
    3. high-level (no code)
    4. customizable to the context

    So far incorporating domain-specific service nodes was only possible within the Drools Flow Eclipse Plugin. (For more info check out the jBPM docs as well this great video).
    We have now added support for domain-specific service nodes to the Oryx web designer. This allows users to create fully executable BPMN2 processes including domain-specific service nodes, all inside Guvnor.

    This video shows how you can use can create new or use your existing domain-specific service nodes inside the Oryx designer (quicktime movie available here). You can also start playing with this by downloading the designer from here as well as Guvnor 5.2.0.CR1.

    You can download the sources of the demo presented in the above video from here.

    Wednesday, May 25, 2011

    Speaking at Big Tech Day (Munich May 27th, 2011)

    I'll be speaking at the Big Tech Day event, sponsored by TNG.
    The Event
    The BTD4 The Big Techday 4 is a one-day conference on science and technology, particularly IT.
    Language The conference language is German. However, several talks, especially from invited speakers, are given in English.
    Time The Big Techday 4 is scheduled for the 27th of May, 2011 in Munich. Admittance opens at 8:30. The programme is running from 9:00 up to about 17:30, with a lunch break. A relaxed evening reception runs up to about 22:00.
    Venue The venue is the HVB Forum in the Munich city center.
    Food During the whole event, cost-free catering is provided, including coffee breaks, lunch buffet and a simple dinner.
    Registration Participation in the Big Techday is free of charge. Due to the high number of participants, the registration is closed. In case of questions please talk to the person that invited you.


    Two Day Drools and jBPM Workshop (Argentina June)

    Thanks to OSDE we now have a 2 day workshop planned in Argentina, Buenos Aries, for June, with nearly all the core Drools and jBPM developers. A MUST attend event for any developer in South America.

    We are just finalising locations, agendas and speakers, we'll give more firm details later, but initially the line up is as follows:

    Where: Argentina (Buenos Aries)
    Date: 16-17 June (Thu/Fri)

    Mark Proctor - Group Lead and Drools co-founder
    Kris Verlaenen - jBPM Lead
    Edson Tirelli - Drools tech Lead
    Geoffrey De Smet - Planner Lead
    Michael Anstis - Business Tooling tech lead
    Ray Ploski - Solutions Architect

    Guest Speakers (so far)
    Salatino Mauricio (Plugtree)

    While us core developers will be focusing on Drools and jBPM, Ray will be there to do talks on AS7, Seam and Infinispan.

    Register here for this free event.

    Tuesday, May 24, 2011

    Drools Planner webinar on Wednesday June 15th

    I'll be presenting a free online webinar on Wednesday June 15th 2011 about Drools Planner. So if you're interested in Planner, put it down in your agenda. The starting time is:
    • 16:00 UTC
    • 18:00 Paris, Brussels, Berlin
    • 17:00 London
    • 12:00 (noon) New York, Washington DC, Boston
    • 09:00 San Francisco
    • 00:00 (midnight) Singapore
    • Show starting time for other cities

    Here is the summary of the 1 hour presentation:
    Drools Planner optimizes automated planning.
    It solves use cases such as:
    • bin packing: filling containers, trucks, ships, cloud computer nodes, ...
    • vehicle/freight/people routing: planning trucks, trains, airplanes, travelling salesmen, repairmen, ...
    • employee shift rostering: rostering nurses, repairmen, ...
    • agenda scheduling: scheduling courses, exams, conference presentations, maintenance jobs, advertisements, ...
    • job shop scheduling: planning assembly lines for building cars, devices, ...
    • cutting stock: cutting paper, steel, carpet, ...
    • sport scheduling: planning football leagues, baseball leagues, ...
    In this presentation, I will:
    • demonstrate some of the use cases and their Drools Planner examples.
    • explain some of the characteristics of these problems, known as NP-complete or NP-hard problems, such as the very surprising search space size.
    • talk about how Drools Planner handles these problems.
    • show how Drools Planner optimizes a lot further than common implementations.
    And of course, there will be time to ask questions.

    Go to the official JBoss webinars webpage for more information.
    Register for the event.

    Friday, May 20, 2011

    Left & Right Unlinking - First Steps.

    Last year Mark posted an entry here talking about the idea of Left & Right Unlinking for Rete networks. I wanted to understand the internals of Drools, so that task seemed a perfect opportunity to dig into the engine. Maybe a little too complex. A month later, Mark came back with Lazily Enabled Truth Maintenance, which felt like an achievable goal, so I decided to give it a shot and posted a patch some days later. I then started to work on Left & Right Unlinking on my spare time and finished a sort of "alpha" version later in November, but with a month of vacations in December plus a hard time coming back to real life, I've just been able to send a pull request last month.

    This first implementation unlinks only the right side of JoinNodes and, once it's linked, never unlink it again. I did tried unlinking also the left side and allowing nodes to link and unlink themselves according to whether or not there were tuples on their left and right memories, but the results were not satisfactory yet with a lot of churn going on. This first simpler version with only the right side unlinked, already shows some improvements on response time and memory usage for rule bases where, for a given session, some of the rules never get executed. That’s usually the case for decision services. If you think your use case falls into this category, give it a try and let us know the results!

    By default all nodes are still linked and nothing is changed in the existing implementation, but you can activate the L&R Unlinking by setting the drools.lrUnlinkingEnabled property to true in your knowledge base configuration. It’s been recently merged and is available with the 5.2.x snapshot.

    The next step is probably to generify the solution to all Beta nodes (it's Join node specific, today) and to try to unlink both sides in a more aggressive way, as described by Mark in the original article.

    Monday, May 16, 2011

    Guarding Drools's performance

    Any new version of Drools Expert should be at least as fast as the previous version and preferably faster.

    Now, that an easy statement to make, but a bit harder to formalize. Any one use case uses many features of the rule engine, such as not, exists, accumulate, ... Different use cases use different feature sets. As powerful new features and improvements are added, it becomes harder to get an overview on the performance of the rule engine. And all these features interact highly and affect the performance and scalability of the rule engine together.

    Therefore micro benchmarks don't always suffice. So we've also been using the real-world examples of Drools Planner as macro benchmarks on Drools Expert. The results are interesting.
    • On average, these benchmarks have 1000+ facts, fire all rules 5000+ times per second and run up to 10 minutes each.
    • They all use the exact same Planner version, but a different Drools Expert version.
    • They are exactly reproducible, because they use a fixed Random seed: only the speed of the rule engine differs.
    • They use a stateful session and benefit (or suffer) greatly from incremental changes: you might or might not experience a similar performance effect in your use cases.
    The graphs show how long it takes to reach a certain score. Lower is better.

    Examination (exam scheduling)

    From 5.0.1 (blue) to 5.1.1 (red) we see a huge performance gain (over twice as fast), as a result of the true modify improvements in 5.1, which were a big jump forward for stateful sessions.

    From 5.1.1 (red) to 5.2.0.M2 (yellow) we see a huge performance drain (reported by Roman Novak), due to a small mistake in a fix for the accumulate implementation. Luckily, Edson located and fixed that mistake, so for 5.2.0.CR1 (green), the rule engine matches the 5.1.1 performance and even slightly improves it (hardly noticeable on the graph).

    Traveling tournament problem (sport scheduling)

    From 5.0.1 (blue) to 5.1.1 (red) we see a good performance gain. And from 5.1.1 to 5.2.0.CR1 (green) we see another good gain, thanks to Mark's Exists/Not improvements.

    But notice the 5.2.0.M2 (yellow) point. The effect of the small accumulate mistake is quite drastic here. It's so slow, that it doesn't even reach the other scores.

    Nurse rostering
    There are no 5.0.1 (blue) points on this graph, because it was too slow. So the true modify improvement of 5.1 really changed the world for this example.

    The effect of the accumulate fix is noticeable in 5.2.0.M2 (yellow). And the Exists/Not improvements result in another good performance gain from 5.1.1 (red) to 5.2.0.CR1 (green).


    Different use cases have different performance stories, but a general trend is noticeable:
    Drools Expert 5.2.0 will be at least as fast (examination) or faster (TTP, nurse rostering) than 5.1.1. And 5.1.1 was already faster (examination, TTP, nurse rostering) than 5.0.1.

    Friday, May 06, 2011

    Feeding CEP events to Drools Fusion using Smooks

    Tom Fennelly published a nice and quick tutorial on how to use Smooks to feed events into Drools. You can read about it here:


    Thursday, May 05, 2011

    Guvnor wars per application server

    In previous Guvnor releases (up to 5.1), it wasn't always easy to successfully deploy the guvnor war to your favorite application server.
    You'd often get a cryptic stacktrace, caused by jars included in the war's WEB-INF/lib directory clashing with jars included in the classpath by the application server. The solution was to somehow locate the offending jars and then remove those jars from the war file.

    From 5.2.0.M2, we're doing this for you. In the guvnor download zip, you 'll find a war file per application server and that war file successfully deploys out of the box. Note that there are no feature or bugfix differences between these wars: each of them provides the same, full-featured guvnor web application.

    Currently we include a war for:
    • JBoss AS 5.1
    • JBoss AS 6
    • Tomcat 6 (which probably works on Tomcat 7 and Jetty 6 and 7)
    Didn't find your favorite application server in there? Just create an assembly descriptor (similar to these) and send us a pull request on github, and we 'll include it.