Drools channels and Apache Camel integration.

The previous posts only showed how to build a route using the Drools endpoint as the target consumer of the message, but what happen if we need to start the route from a Drools endpoint (the source endpoint) and send a message from the rules consequence to the target endpoint? In this case we need to use Drools channels.

A Drools channel provides a mechanism to send objects from the working memory to some external process or functions.
Continue reading

JBoss Drools Developer‘s Cookbook released

Maybe you noticed, or not, that this blog hasn’t had too much activity lately (but hey, I wasn’t blooging much before, right?). Well, one of the reasons was the Drools Developer Cookbook, a book that I was writing and that after a few months of hard work is finally finished and released by Packt Publishing.

Drools Developer's Cookbook cover

Inside this book you will find lots of recipes to apply in your Drools projects, in order to take advantage of the latest features released in JBoss Drools 5.2 and 5.3. It covers all the main modules, Expert, Fusion, Guvnor, Planner and even jBPM5.

I would like to thank Packt Publishing & crew, Edson Tirelli, Geoffrey De Smet, Toni Rikkola and everyone else that in any way helped me.

The chapters 2 & 7 are available to read in the next links:

Expert: behind the rules (Full chapter)
Integration: How to connect Drools (Article)

As always, for further details you can take a look in the book website
http://www.packtpub.com/drools-developers-using-jboss-cookbook/book

Have fun

jBPM5/Drools Apache Camel integration

 

After a few months I’m back with another useful, or maybe not, post about the integration between Apache Camel and Drools/jBPM5. I decided to write this post because 1) people are continuously asking about the last changes in the integration and 2) I already had a POC using the last Drools/jBPM5/Camel integration in my github account.

So, in this example I’m going to explain how to use jBPM5 together with Apache Camel but the same concepts and configuration can be applied to a Drools integration with Camel.
Continue reading

Drools Metrics Persistence

I would like to introduce a small project that I developed at @plugtree in the last months. It’s a project to monitor and persist internal metrics of Drools Knowledge Session’s. This will allow you to gather internal metrics information of the knowledge base and sessions registered into the JVM (local or remote) using the Drools JMX API and persist this information into a database (right now it’s using Hibernate as the ORM but it’s pluggable enough to use another persistence framework, which should be the ideal because of the huge amount of data to be stored). As you can imagine it’s really useful to use to create your custom dashboard to monitor how healthy are your knowledge session´s, to made predictive analysis, etc.

It currently supports the following features, but there are more coming:

  • knowledge base auto discovery.
  • knowledge sessions auto discovery.
  • configurable knowledge scanners.
  • pluggable persistence framework.
  • spring framework configuration friendly.

Continue reading

Drools Flow migration to jBPM 5

If you are smart and wants to migrate from Drools Flow to jBPM 5 remember to configure the processInstanceFactory and processSignalFactory, using a Properties object or configuring them into the drools.conf file, before the creation of a KnowledgeSession.

Properties properties = new Properties();
properties.put("drools.processInstanceManagerFactory", 
   "org.jbpm.process.instance.impl.DefaultProcessInstanceManagerFactory");
properties.put("drools.processSignalManagerFactory", 
   "org.jbpm.process.instance.event.DefaultSignalManagerFactory");
KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(config, EnvironmentFactory.newEnvironment());

otherwise you’ll obtain this RuntimeException

java.lang.RuntimeException: java.lang.ClassNotFoundException: Unable to load class: org.drools.process.instance.impl.DefaultProcessInstanceManagerFactory

Drools Camel Integration

The Apache Camel integration allows us to interact with a Drools Stateless or Stateful session through a pipeline. It basically works by transforming XML commands into executable commands and executing each of them. The advantage of this integration is that Apache Camel makes possible the implementation of more advanced enterprise integration patterns, which is an improvement of Drools Pipeline.

This integration with Drools allows us to add any of the current Camel components. Using the Apache Components you can, receive commands from several entry points and send the execution result to another entry point. Just to name a few of the components: JMS queue/Atom Feed/Mina connection/a Mail/etc. As you can see, this brings a more powerful interoperability mechanism to integrate your application with Drools. Actually Drools is using Camel 2.4.0 that allows a more strong internal integration between them.

Introduction to Drools Grid
This integration is coupled with another drools module called: drools-grid. This module allow us to interact with Drools sessions independent of the JVM location. At the moment we can use two implementations:

  • Local: Used when the drools sessions and clients are in the same JVM
  • Remote: Used when you have drools sessions on a remote JVM. Currently, the only implementation is based on Apache Mina. HornetQ support is actually done, but don’t available in trunk

Drools Grid is embedded inside the Drools Camel component, so don’t worry about further implementation information because this is hidden by Drools. With this information we can start to configure our Camel Context.
Continue reading

Drools Server configuration updated

In the past days Drools Execution Server was updated to use a new version of the Drools Camel integration and more features were added.
One of the biggest differences is that now everything is configured using Spring, and no java code is included inside the WAR file. And, opposite to the previous version, SOAP isn’t supported out-of-the-box (you could use SOAP in the previous version) but you can add your own support right now.

Configuration
As in the previous version, the configuration files are included in the WEB-INF/ folder inside the WAR file. Now we have three configuration files: beans.xml, camel-server.xml and knowledge-services.xml

  • beans.xml: It is the main xml file, but only is used to import the next two files. So, you don’t need to modify this one.
  • camel-server: This file includes the configuration of REST interface and Camel routes.

Let’s go to do a deep configuration review…
Continue reading