Wednesday, January 26, 2011

Getting started with jBPM 5 (Vignesh Dhakshinamoorthy)

Vignesh has kindly created a "Getting started with jBPM 5" video. He's put it up on his blog here:
http://viki-the-techie.blogspot.com/2011/01/getting-started-with-jbpm-5.html

(extract)
"I once wrote a blog on setting up jBPM 3 with jBoss ESB which proved useful to lot of folks. Now I am going to present a similar one for the all-new jBPM5. There is indeed a huge difference between the two and I must admit that the new product stack is looking very good, loaded with many must-have options any BPM product should ship with.
I will write about all the technical insights in a separate post. One good news you should know is that the installation has got a lot easier in this version. Let's just get started with jBPM 5, install it, and see it for ourselves.
...snip...."

Thursday, January 20, 2011

JDK1.5 Future for Drools and jBPM

Dropping JDK1.5 is something that rears it's head from time to time, and we know we have to address it sooner or later.

We recognise that the majority of people would like to see JDK1.5 dropped, but there are still a few large critical enterprises using Drools and jBPM on JDK1.5.

Technically for us there isn't a huge advantage, and certainly no "must have" feature, in the same way that moving from 1.4 to 1.5 was. However it does make the project easier to manage: less runtime targets to test against and we don't need to double check people are putting JDK1.6 only classes in Drools and jBPM.

My personally opinion is that we need a widest audience possible for the up coming jBPM5 release and we still have some critical things I'd like to see in Drools first. So personally I'd like to wait until the last few months of this year, say October, before dumping JDK1.5; which would allow for a very late 2011 release or very ealry 2012 release that is JDK1.6+.

What do people think? Comments welcome, I've also added a poll on the right side.

Mark

Tuesday, January 18, 2011

A process repository using Guvnor

One of the missing pieces in the jBPM 5.0 CR1 release was the inclusion of a process repository. Luckily, your waiting time is over!

A process repository is an important part of your BPM architecture if you start using more and more business processes in your applications and especially if you want to have the ability to dynamically update them. The process repository is the location where you store and manage your business processes. Because they are not deployed as part of your application, they have their own life cycle, meaning you can update your business processes dynamically, without having to change the application code.

Note that a process repository is a lot more than simply a database to store your process definitions. It almost acts as a combination of a source code management system, content management system, collaboration suite and development and testing environment. These are the kind of features you can expect from a process repository:
  • Persistent storage of your processes so the latest version can always easily be accessed from anywhere, including versioning
  • Build and deploy selected processes
  • User-friendly (web-based) interface to manage, update and deploy your processes (targeted to business users, not just developers)
  • Authentication / authorization to make sure only people that have the right role can see and/or edit your processes
  • Categorization and searching
  • Scenario testing to make sure you don't break anything when you change your process
  • Collaboration and other social features like comments, notifications on change, etc.
  • Synchronization with your development environment
Actually, it would be better to talk about a knowledge repository, as the repository will not only store your process definitions, but possibly also other related artefacts like task forms, your domain model, associated business rules, etc. Luckily, we don't have to reinvent the wheel for this, as the Guvnor project acts as a generic knowledge repository to store any type of artefacts and already supports most of these features.

The following screencast shows how you can upload your process definition to Guvnor, along with the process form (that is used when you try to start a new instance of that process to collect the necessary data), task forms (for the human tasks inside the process), and the process image (that can be annotated to show runtime progress). The jbpm-console is configured to get all this information from Guvnor whenever necessary and show them in the console.


If you use the latest snapshot version of the jbpm-installer, that should automatically download and install the latest snapshot of Guvnor as well. So simply deploy your assets (for example using the Guvnor Eclipse integration as shown in the screencast, also automatically installed) to Guvnor (taking some naming conventions into account, as explained below), build the package and start up the console.

The current integration with the jbpm-console uses the following naming conventions to find the artefacts it needs (though we hope to update this to something more flexible in the near future):
  • All artefacts should be deployed to the "defaultPackage" on Guvnor (as that is where the jbpm-console will be looking)
  • A process should define "defaultPackage" as the package name (otherwise you won't be able to build your package on Guvnor)
  • Task forms that should be associated with a specific process definition should have the name "{processDefinitionId}.ftl"
  • Task forms for a specific human task should have the name "{taskName}.ftl"
  • The process diagram for a specific process should have the name "{processDefinitionId}-image.png"
If you follow these rules, your processes, forms and images should show up without any issues in the jbpm-console.

Monday, January 17, 2011

Two Part Drools and Guvnor Tutorial (Brian Du Preez)

Part 1 (Brian Du Preez)
Part 2 (Brian Du Preez)

Part 1 (Excerpt - Brian Du Preez)
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
...
...


Recent jBPM 5 blogs, articles, videos and presentations

I've put together a list of jBPM 5 references over more recent months to help people find interesting things to read or watch. Please let me know if anything else should be added to the list.

jBPM5 RoadMap
Introduction to jBPM5
Event Driven Business Process Management in jBPM5
Are you ready for Drools 5.2 + jbpm5
Here we go... first jBPM5 Snapshot
Towards case management
jBPM 5.0 CR1 is out
Migrating to jBPM5
jBPM migration tool update
jBPM5 Webinar (video)
jBPM5 JudCon 2010 (slides)
Human Task Example
Emergency Services Demo Application (video)
Building jBPM5 From Source
jBPM5 and BPMN2.0
Drools Flow Migration to jBPM5
jBPM5 to be integrationed into Maven Shell
Building up a flexible Service Request Workflow (I)
Building up a flexible Service Request Workflow (II)
Building up a flexible Service Request Workflow (III)
Building up a flexible Service Request Workflow (IV)

Saturday, January 15, 2011

Do you have a bin packing problem or vehicle routing problem?

I am looking for a good bin packing problem or a good vehicle routing problem to implement as an example in Drools Planner. So if your company has a situation similar to these, consider contacting me (or replying to this blog):
  • It has to fill containers with boxes. It wants to minimize the number of containers used.
  • It needs to service a number of customers with a fleet of vehicles. For example an airline, a train company or freight distributing company.
  • It has a paper mill and needs to cut fixed-sized paper rolls into various-sized paper widths (per customer order). It wants to minimize the waste.
A couple of people have already implemented such problems in Drools Planner, but there's no official open source example yet, to show some of the best practices and implementation details. Furthermore, many companies don't realize they can save a lot of money and severely lower their ecological footprint by optimizing their planning.

What's in it for you? You get a free (ASL licensed) prototype, tailored to your planning problem. It should be straightforward to copy that into your (proprietary) company code and integrate it with your live systems.

What do I need from you? A couple of things:
  • Real-world data sets
    • Preferably in XML or TXT format
    • Each data set should be a planning instance that occurred in the past.
    • Preferably at least 5 historical data sets
    • All data that is not relevant for the planning problem should be pruned.
    • If it contains sensitive data (such as employee names), that data should be obfuscated.
  • A clear data format description, except if it is readable XML.
  • A clear description of the hard and soft constraints. For example:
    • HARD: Each airplane cannot transport more passengers than its number of passenger seats.
    • SOFT: Each airplane has a fuel price per km (depending on it's size). Minimize the cost.
    • SOFT: Each airplane has an airport tax per landing. Minimize the cost.
  • It should be possible to calculate the entire cost of a solution in $ or €.
    • And preferably also in liters of fuel or CO² emission or any other ecological footprint.
    • If possible, each historical data set should contain the solution that was executed originally in the past, so we can calculate the original cost and footprint and compare it with the optimized solution, to clearly show the cost and ecological footprint reduction.
  • All this information must be made available under the ASL license because it will be added to the Drools Planner examples.

Thursday, January 13, 2011

Rules-based Validation using Drools, JSR303 and Spring (Patrick van Kann)

Original Article(Patrick van Kann)
http://nonrepeatable.blogspot.com/2010/11/rules-based-validation-using-drools.html

Rules-based Validation using Drools, JSR303 and Spring

Validation and business rules are closely linked. Indeed validation logic could be thought of as being part of the implicit business rules for an application.It seems natural that integrating a business rules solution with a validation technology might be a natural step. In this post, I explore the possibility of integrating JSR303 and Drools to provide business rule driven validation within a Spring application. JSR303 is the standard Java method for data validation using annotations and Drools is a business rules engine that is a JBoss project and an implementation of JSR94, the standard Java rule engine API.

When to use (and when not to)

I don't think that this is a natural choice for all data validation needs. For a start, if the validation in your application is simple, the standard JSR303 annotations mixed with a few custom annotations might be enough. Integrating Drools comes at a cost in terms of architectural complexity and additional dependencies for you application. And although Drools is highly performance-optimised, a set of business rules in Drools will probably be slower than a set of custom Java statements.

However, there are significant benefits to complex applications - particularly if you are using Drools already. In that case, the complexity and dependency arguments are not valid.

The big benefit is the ability to externalise the business rules from the application and enable them to be edited without redeploying the application.

Drools overview

In a Drools application, business rules can be written in a powerful expression language called mvel (although XML can be used as well). In the Drools Expert documentation, the following basic example is given.
package com.company.license;

public class Applicant {

private String name;

private int age;

private boolean valid;

// getter and setter methods here

}
package com.company.license;

rule "Is of valid age"
when
$a : Applicant( age < 18 )
then
$a.setValid( false );
end
The rule consists of conditions (when) and consequences (then). In this rule, when the Applicant age property is less than 18, the valid property is set to false.

Often, business rules will need to access collaborators such as services or DAOs. These can be injected as "globals" in the rule definition. For example, the scenario above could be modified so that the applicant needs to be loaded from a DAO in order to check the age. The applicant identifier is a property in an ApplicationForm, submitted from a GUI or web application.We'll also introduce a new class to hold the validation result, rather than setting the validity on the model object itself, which is somewhat artificial. This object could be returned to the presentation tier to tell the user what went wrong.Error object to hold validation result:
package com.acme.app.validation;

import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Errors {

private final List<Error> errors = Collections.synchronizedList(new ArrayList<Error>());

public Collection<Error> getErrors() {
return Collections.unmodifiableCollection(errors);
}

public void addError(Object target, String field, String message) {
this.errors.add(new Error(target, field, message));
}

public boolean hasErrors() {
if (this.errors.size() > 0) {
return true;
}
return false;
}
}

class Error {
private final Object target;
private final String field;
private final String message;

public Error(Object target, String field, String message) {
super();
this.target = target;
this.field = field;
this.message = message;
}

public Object getTarget() {
return target;
}

public String getField() {
return field;
}

public String getMessage() {
return message;
}
}
Modified Applicant (with identity)
public class Applicant {

private int id;

private String name;

private int age;

private boolean valid;

// getter and setter methods here

}
ApplicationForm from the GUI/web:
public class ApplicationForm {

private int applicantId;

private Date date;

// getter and setter methods here

}
Here is a slightly silly test DAO:
public class ApplicantDaoImpl implements ApplicantDao {

private final Map<Integer, Applicant> applicants = new HashMap<Integer, Applicant>();

public ApplicantDaoImpl() {
Applicant app1 = new Applicant(1, "Mr John Smith", 16);
applicants.put(app1.getId(), app1);
Applicant app2 = new Applicant(2, "Mr Joe Bloggs", 21);
applicants.put(app2.getId(), app2);
}

@Override
public Applicant findApplicant(Integer identifier) {
return applicants.get(identifier);
}

}
Finally, a rule with a global representing the ApplicantDao and using our new Errors object could look like:
package com.acme.app.rules

import com.acme.app.form.ApplicationForm
import com.acme.app.model.Applicant
import com.acme.app.validation.Errors
import com.acme.app.dao.ApplicantDao

global ApplicantDao applicantDao

package com.acme.app.rules

import com.acme.app.form.ApplicationForm
import com.acme.app.model.Applicant
import com.acme.app.validation.Errors
import com.acme.app.dao.ApplicantDao

global ApplicantDao applicantDao

rule "Check applicant age"
when
$a : ApplicationForm()
$errors : Errors()
$applicant:Applicant( age < 18 ) from applicantDao.findApplicant($a.getApplicantId())
then
$errors.addError( $a, "applicantId", "Applicant age < 18" );
end
In this version of the rule, the applicant is loaded from a DAO based on their identity. If the age of the applicant is less than 18, an error is inserted into the Errors object specifying the target object, field and message to return to the GUI. Obviously, this could be internationalized by putting a message code instead of the actual message.

That's an extremely brief overview of rules. Next, I'll quickly discuss the main API that Java programmers use when interacting with Drools. These will be used by the JSR303 validator when validating a bean using business rules.

At the most basic level, Drools stores business rules in a KnowledgeBase, from which can be created "sessions" which enable users to execute the rules based on facts, which are usually model objects inserted into the session.

There are two types of session: StatefulKnowldegeSession and StatelessKnowledgeSession. A StatelessKnowledgeSession is considered appropriate for use cases such as validation, because they are intended as a "one-shot" function call: pass in the facts, execute the rules, get a result. That's therefore the interface I will use for the integration with a JSR303 validation.
Here is a simple example of creating a StatelessKnowledgeSession and executing the rules based on a collection of facts, each of which is inserted in turn before the rules are fired.
 KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newFileSystemResource( fileName ), ResourceType.DRL );
assertFalse( kbuilder.hasErrors() );
if (kbuilder.hasErrors() ) {
System.out.println( kbuilder.getErrors() );
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );

StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
ksession.execute( collection );

Spring integration

Conveniently, in Drools 5.1 some additional Spring integration was added that enables you to create KnowledgeBases and sessions declaratively in the application context, using a purpose-built namespace.

In this example, Spring is the "glue" bringing together the Drools and JSR303 parts. Here's the configuration.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://drools.org/schema/drools-spring http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd">

<drools:kbase id="kbase">
<drools:resources>
<drools:resource type="DRL" source="classpath:testSpring.drl"></drools:resource>
</drools:resources>

</drools:kbase>

<drools:ksession id="statelessKSession" type="stateless" name="statelessKSession" kbase="kbase"></drools:ksession>

</beans>
I'm keeping things very simple - there is a lot more that the namespace can do in terms of configuring knowledge bases, agents, sessions etc.

JSR 303 Overview

JSR303 is a standard Java mechanism for validating JavaBeans using convenient annotations. Creating custom annotations is a matter of creating the annotation and an accompanying ConstraintValidator implementation, which will be automatically used by the Validator when it encounters the annotation on a bean getting validated.

The annotation itself is simple.
package com.acme.app.validation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy=BusinessRulesConstraintValidator.class)

public @interface BusinessRulesConstraint {
String message() default "Business rules validation failed.";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
The validator is also reasonably simple. A StatelessKnowledgeSession and a simple bean carrying a Map of the needed collaborators (to be set as globals) are injected into the constructor.
When the isValid() method is called, an Errors object and the target of the validation are inserted into the session and the validation rules are fired. If the Errors object comes back with errors, validation has failed and a ConstraintViolation is built using the data in the Errors object.
package com.acme.app.validation;

import java.util.Arrays;
import java.util.Map;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.StatelessKnowledgeSession;
import org.springframework.beans.factory.annotation.Autowired;

/**
* Custom JSR303 {@link ConstraintValidator} that
* uses a Drools {@link StatelessKnowledgeSession} to
* implement rules-based validation of objects
* decorated with a @BusinessRulesConstraint annotation
*/
public class BusinessRulesConstraintValidator implements ConstraintValidator<BusinessRulesConstraint, Object> {

private final Log logger = LogFactory.getLog(BusinessRulesConstraintValidator.class);

private final StatelessKnowledgeSession session;

@Autowired
public BusinessRulesConstraintValidator(StatelessKnowledgeSession session, Collaborators collaborators) {
this.session = session;
if (collaborators != null) {
Map<String, Object> map = collaborators.getCollaborators();
for (String key : map.keySet()) {
session.setGlobal(key, map.get(key));
}
}
}

@Override
public void initialize(BusinessRulesConstraint constraint) {}

@Override
public boolean isValid(Object target, ConstraintValidatorContext context) {

// Create Errors
Errors errors = new Errors();

try {

// Fire rules
session.execute(Arrays.asList(new Object[]{errors, target}));

// Check for errors
if (errors.hasErrors()) {
// Build constraint violations
context.disableDefaultConstraintViolation();
for (Error error : errors.getErrors()) {
context.buildConstraintViolationWithTemplate(error.getMessage()).addNode(error.getField()).addConstraintViolation();
}
return false;
}
}
catch (Exception e) {
logger.error(e);
return false;
}

return true;
}

}
The Collaborators object is extremely simple:
package com.acme.app.validation;

import java.util.Collections;
import java.util.Map;

public class Collaborators {

private final Map collaborators;

public Collaborators(Map collaborators) {
super();
this.collaborators = collaborators;
}

public Map getCollaborators() {
return Collections.unmodifiableMap(collaborators);
}
}
It's simply a container holding a map into which collaborators such as DAO or Service facades could be injected using Spring.
The full Spring configuration gluing the whole thing together is below:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://drools.org/schema/drools-spring http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd">

<drools:kbase id="kbase">
<drools:resources>

<drools:resource type="DRL" source="classpath:testSpring.drl"></drools:resource>
</drools:resources>
</drools:kbase>

<drools:ksession id="statelessKSession" type="stateless" name="statelessKSession" kbase="kbase"></drools:ksession>

<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"></bean>

<bean id="collaborators" class="com.acme.app.validation.Collaborators">
<constructor-arg> <map>
<entry key="applicantDao" value-ref="applicantDao"></entry>

</map>
</constructor-arg> </bean>

<bean id="applicantDao" class="com.acme.app.dao.impl.ApplicantDaoImpl"></bean>
</beans>
Using the validator is very simple. First, the ApplicantForm object needs to be decorated with the @BusinessRulesConstraint annotation at class level so that the JSR303 validator will be triggered to use the BusienssRulesConstraintValidator.
package com.acme.app.form;

import java.util.Date;

import com.acme.app.validation.BusinessRulesConstraint;

@BusinessRulesConstraint
public class ApplicationForm {

private Integer applicantId;

private Date date;

// getters/setters
}
Then it is a matter of invoking the validator with a bean instance like this:
package com.acme.app.validation.tests;

import java.util.Date;
import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.Validator;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.acme.app.form.ApplicationForm;

public class ValidationTestCase {

private static ApplicationContext ctx;

private static Validator validator;

@BeforeClass
public static void beforeClass() {

// Create the Spring application context
String[] paths = { "application-context.xml" };
ctx = new ClassPathXmlApplicationContext(paths);

}

@Before
public void before() {
validator = (Validator)ctx.getBean("validator");
}

@Test
public void testInvalidAge() {
ApplicationForm applicationForm = new ApplicationForm(1, new Date());
Set<ConstraintViolation<ApplicationForm>> violations = validator.validate(applicationForm);
Assert.assertNotNull(violations);
Assert.assertEquals(Integer.valueOf(2), Integer.valueOf(violations.size()));
}

}

Summary

This post shows you an approach for integrating JSR303 and Drools in a Spring application, something you might want to do if you were using these technologies already in your application and it was sufficiently complex to warrant it. The steps involved are:
  • Create your domain objects and decorate them withe @BusinessRulesConstraint where business rule validation is to be used.

  • Create the .drl file with your validation logic in it.

  • Configure Spring as above with a KnowledgeBase containing your drl file as a resource, a StatelessKnowledgeSession derived from that KnowledgeBase, your collaborators for the rules and the JSR303 validator.

That's it!

Postscript: Maven configuration

For Maven users, this should be useful in getting all the dependencies for this example to work.
<dependencies>

<!-- Spring bits -->
<dependency>

<groupid>org.springframework</groupId>
<artifactid>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupid>org.springframework</groupId>

<artifactid>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>

<dependency>
<groupid>org.springframework</groupId>
<artifactid>spring-beans</artifactId>
<version>${org.springframework.version}</version>

</dependency>

<!-- Drools bits -->
<dependency>
<groupid>org.drools</groupId>
<artifactid>drools-core</artifactId>
<version>5.1.1</version>
</dependency>

<dependency>

<groupid>org.drools</groupId>
<artifactid>drools-spring</artifactId>
<version>5.1.1</version>
</dependency>

<!-- JSR303 bits -->
<dependency>
<groupid>org.hibernate</groupId>

<artifactid>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>

<dependency>
<groupid>org.slf4j</groupId>
<artifactid>slf4j-api</artifactId>

<version>1.5.6</version>
</dependency>

<!-- concrete Log4J Implementation for SLF4J API-->
<dependency>
<groupid>org.slf4j</groupId>
<artifactid>slf4j-log4j12</artifactId>
<version>1.5.6</version>

</dependency>

</dependencies>

Tuesday, January 11, 2011

Drools Content Based Routing with Camel (John Ellis)

John Ellis has done a nice writeup of his work on improving Drools to work with Camel for CBR. You'll need to use the latest version of Drools from trunk, which can be found in the maven repository that's 5.2.0-SNAPSHOT, https://repository.jboss.org/nexus/content/groups/public/org/drools/.

For bonus points I'd love to see a further Drools and Camel tutorial around OSGi's EventAdmin, http://camel.apache.org/eventadmin.html.

--- (John Ellis) ---
One of Camel's greatest strengths is the explicit support for Enterprise Integration Patterns. Drools itself is particularly well suited to work alongside Camel to implement two commonly used integration patterns: the Content Based Router and the Dynamic Router. Both patterns leverage the ability of a Drools Endpoint to rapidly evaluate properties of a message, while the Dynamic Router can also integrate the Drools Policy as a dynamic rule based on feedback from a control channel.

The Camel routes required for message routing do not differ much from the previous Drools Endpoint example. You may even be able to omit the Drools Policy if you wish to inspect only the headers of messages being routed instead of interrogating the body of each message. For example, a DRL could be defined that takes action on inbound messages such as:

import org.apache.camel.Message;
rule "WriteOperations"
when
$message : Message(headers["OPERATION"] == "WRITE");
then
$message.setHeader("routingSlip", "activemq:queue:op.write");
end

rule "ReadOperations"
when
$message : Message(headers["OPERATION"] == "READ");
then
$message.setHeader("routingSlip", "activemq:queue:op.read");
end

Example 1: DRL for Routing Based on Message Headers

Here the custom header “OPERATION” is evaluated to see if it is set to the value “WRITE” or “READ.” Depending on the value of this header, a routing slip is defined for the message. The Routing Slip is another Enterprise Integration Pattern supported by Camel that may contain one or more URIs. The message is then sequentially sent to each URI defined.

The Camel routing itself is simply defined as:

<route>
<from uri="activemq:queue:router"/>
<to uri="drools:brokerNode/cbrKSession?action=insertMessage"/>
<routingSlip uriDelimiter="#">
<header>routingSlip</header>
</routingSlip>
</route>

Example 2: Camel Routes for Content Based Routing

Here we explicitly inform Camel that routing slips are defined as values within the “routingSlip” header and each URI is delimited by a # character. The headers set within the DRL are then interpreted as each message exits the Drools endpoint.

Content based routing with a Drools Endpoint offers several advantages over Camel's default implementation. The DRL format itself allows routing to be specified more succinctly than Sprint DSLs or Camel RouteBuilders. Conditional operations are also evaluated more efficiently within Drools and are thread-safe, allowing a high volume of messages to be routed concurrently.

Bay Area meetup (Antoine Toulme) (Re-post)

Posted from email discussion:
http://drools-java-rules-engine.46999.n3.nabble.com/Bay-Area-meetup-td2008387.html
---
If you are in the SF Bay Area, Intalio would like to invite you to a meetup on Thursday January 13th at Intalio HQ.

We want to build a Drools community in the bay, and we would like to introduce what Intalio is doing with Drools there.

We're interested into getting to know the Drools users some more as well.
http://www.blogger.com/img/blank.gif
Our address is:
644 Emerson St
Suite 200
Palo Alto

We're next to Gordon Biersch, up the stairs.

Please register using Eventbrite here:
http://intaliodrools.eventbrite.com/


Thanks,

Antoine

Monday, January 10, 2011

Mythic Game Project Addition Artificial Intelligence and Quest System Components (Christopher Alan Ballinger)

Google Alerts brought this extensive masters paper to my attention, by Christopher Alan Ballinger. The paper explains what expert systems are and has a lot of DRL examples to follow.
http://www.csci.csusb.edu/turner/690/example_projects/chris_ballinger_masters_project.pdf

I'd be interested to see this code published online for others to play with.

"In this project, we describe the design decisions and principles behind the arti cial intelligence (AI) for a multiplayer online role playing game, and our use of an expert system to implement it. We explain how we organize AI rules into les, how those rules are assembled from a database, how AI is assigned to entities, the di erent types of AI, the di erent phases of AI, and how we manage facts used by AI. We also review some of the history behind the Mythic project, where it is headed, what an expert system is and why we chose to use one for our project. The result of our project is a design that allows us to have diverse AI behavior and exibility to reuse code to create new behaviors, but may prove to be ineffcient if implemented on systems with many players or many instances of AI running."

Friday, January 07, 2011

Emergency Service Drools Application

Hi there, the following video shows the Emergency Service Drools Application. This application show Drools and jBPM5 in action. We will be updating this application to show an end to end application using all the platform features.



(video link)

(github repo renamed -> https://github.com/Salaboy/emergency-service-drools-app)

You can get the source code cloning the github repo:

https://github.com/Salaboy/emergency-service-drools-app

Read more about it in:

Please give us feedback and feel free to join us adding new features, forking the app or asking for new features!

Original Post: http://wp.me/pbXhi-ov

Tuesday, January 04, 2011

Drools 5.1 Human Task Example (TC_ONG)

full article:
http://technodeck.blogspot.com/2011/01/drools-51-human-task-example.html

---partial paste below---
It has been a while seen my last post. Lately I have been working on BPMS and Drools. I try to create a simple app using Drools Flow and Human task and now have some small success.
While learning and creating my simple app, looking for example online was difficult. Try google "Drools 5.1 Human Task Example" and see what you will get. So I decide to put more example online for reference. It may not be as complete but I'll show the parts that is working.

What I try to do is like this.

Sunday, January 02, 2011

Configuring multiple Guvnor instances in a Jackrabbit cluster

We added a new task in drools-ant which helps with configuring multiple Guvnor instances to be able to share their Jackrabbit content. Each Guvnor instance is configured as a node to the underlying Jackrabbit cluster. The ant task itself is pretty simple and can look for example:




In this example we define a 2 node Jackrabbit cluster. All changes/updates on one node will be synchronized across all other nodes in the cluster. The task creates the Jackrabbit repository.xml file for each node and writes them into directories $destinationdir/01/repository.xml and $destinationdir/02/repository.xml respectively.
These configuration files define the node's clustering configuration, for example:




Copy the produced repository.xml files to your Guvnor instances (in $jboss/bin for example or the directory specified for repository.root.directory in drools-guvnor.war/WEB-INF/components.xml) and start them up. You can play with the sync delay value to make sure it fits your needs.

Currently the ant task supports following databases: MySQL, MS SQL, PostgreSQL, and Oracle(9i,10g,11).
You can find more information on Jackrabbit clustering here.

Many thanks to our friend João Paulo Viragine for his help on the PostgreSQL configuration.

Saturday, January 01, 2011

JIRA-DROOLS Developer and Testing consultant (Job Advert)

I saw this job advertised and thought it looked pretty interesting, atleast different to other drools jobs I've seen advertised. It will be interesting to see what Drools based plugins for JIRA look like. So if anyone gets the job, do send us a case study :). The CTBTO is the "preparatory commission for the comprehensive nuclear-test-ban treaty organisation"

http://www.ctbto.org/employment/consultancy/vaidc0031-2011jira-drools-developer-and-testing-consultant/?jobid=389

JIRA and Confluence development
•The consultant will design, develop, test and document modules and plugins for JIRA and DROOLS based on PTS requests. The modules for JIRA cover a wide range of possibilities, from simple GUI adjustments to complex system integration connectors to automatic workflow transitions to customized notifications to specific application functionalities including interfaces from JIRA to external systems and from external systems to JIRA.

•The framework to be used is “The Atlassian Plugin Framework 2” which is a library for developers provided to extend the functionality of Atlassian applications such as JIRA, Confluence and others. The plugin framework is part of the new plugin development platform presented by Atlassian (http://confluence.atlassian.com/display/DEVNET/Development+Platform+for+Plugin+Framework+2).

DROOLS development
•Collaborate in the design, development and testing of solutions oriented to implement Business rules in the alert system based on DROOLS.
Develop Operational Procedures
•Collaborate in the development of operational procedures for adopting the new monitoring and reporting systems in Operations.

Contribute to the Operations Centre activities
•Participate in the operational transition to the new State of Health tool at the Operation Center to ensure that the business rules are implemented.
•Participate in the development of software tools for the Operations Centre and for monitoring of the network.


update (4//1/2011) from original author:

Hi,

I´m one of the persons behind this project in the CTBTO, I would like to encourage anyone interested in the job to apply for it even in you don´t have an extended JIRA background.

I will be checking back this post, incase you anyone is interested