Tuesday, April 28, 2009

Monitoring for changes in repository

A feature in Guvnor 5 that might not be obvious is atom feeds (like RSS feeds) for different things: specifically Category listings, and package listings. Using a feed reader of your choice (below is NetNewsWire) you can "listen" for changes to assets (each change will result in a new item in a feed, effectively). Opening it in a web browser will open just that item...


Handy for being notified of changes... the icon is the feed icon on list screens (paste that URL into a feed reader). It is an authenticated feed of course....

Thursday, April 23, 2009

San Francisco Boot Camp for June filling up fast

We now have 35 registered people for the boot camp, so places are filling up fast. If you are thinking of joining, do hurry to avoid disappointment.

Details of the boot camp can be found here.

Wednesday, April 22, 2009

The BPM Technology Convergence

Winston Dhanraj, over at ZDNET, has run two articles on BPM technology convergence, where he discussed rules and process integration and gives a nod to the direction Drools is heading and it's role in helping industry adoption of these ideas. It's an interesting articles, and Winston definitely seems to be singing from the Drools hymn sheet, as this is a vision we have been pushing for a while now.
The BPM Technology Convergence - I
The BPM Technology Convergence - II

"A Converged or Unified Process & Rules Engine brings forth a few striking capabilities by virtue of it being “Rule driven”."

"The BPM industry is taking note of innovations such as the one we have discussed – a Unified process & rules engine platform for deploying BPM solutions."

"The technology however has some compelling merits. It seems to directly address the heart of real world BPM problems of dynamic process configurability or context driven adaptable/agile process flows and consistent process and rule versioning"

Wednesday, April 15, 2009

Not one but two Drools books

I already blogged Paul Brown's Drools book release here. Now I hear there is another Drools book on the way by Michal Bali, also in Ireland.

What's great about this is it adds another level of consideration to enterprises considering adopting rule engine technology. With any software choice there are risks that need to be assessed. Things like how easy is it to hire people skilled in those technologies or find consultancies that offer services for those technologies. The more prevalent the software the lower the risk of those issues. Books are a good tide mark of how prevalent a technology is. With not one but two Drools books on the way, I think it's safe to say that Drools has gone a long way to reducing the perceived risk of it's adoption compared to other "major" vendors who don't warrant enough market share for a publisher to publish a book.

Drools JBoss Rules 5.0 Developer's Guide

In Detail
Business rules can help your business by providing a level of agility and flexibility. As a developer, you will be largely responsible for implementing these business rules effectively, but implementing them systematically can often be difficult due to their complexity. Drools, or JBoss Rules, makes the process of implementing these rules quicker and handles the complexity, making your life a lot easier!

This book guides you through all of the features of Drools, such as dynamic rules, the event model, and Rete implementation with high performance indexing. It will help you to set up the JBoss Rules platform and start creating your own business. It's easy to start developing with Drools if you follow its real-world examples that are intended to make your life easier.

Starting with an introduction to the basic syntax that is essential for writing rules, the book will guide you through validation and human-readable rules that define, maintain, and support your business agility. As a developer, you will be expected to represent policies, procedures and. constraints regarding how an enterprise conducts its business; this book makes it easier by showing you it can be done.

A real-life example of a banking domain allows you to see how the internal workings of the rules engine operate. A loan approval process example shows the use of the Drools Flow module. Parts of a banking fraud detection system are implemented with Drools Fusion module, which is the Complex Event Processing part of Drools. This in turn, will help developers to work on preventing fraudulent users from accessing systems in an illegal way.

Finally, more technical details are shown on the inner workings of Drools, the implementation of the ReteOO algorithm, indexing, node sharing, and partitioning.

Drools Boot Camp - Ales Justin to do Micro Container Talk

Ales Justin, the JBoss Microcontainer lead, is to do a talk about Drools integration with MC. So we now have three lightning talks for the Drools boot camp. Any more takers?

JBoss Drools Business Rules (Paperback) now on Amazon

The Books is now available on amazon here.

You can read Paul's announcement in his blog here.

Drools Boot Camp (SF 2009) are filling up fast

Places for the boot camp in San Francisco this June are filling up fast, and the Hilton has just increased it's room rate - the cheapest room has moved from $103 to $127.

Details of the Boot Camp can be found here.

We are still looking for more people to do lightening talks, so if you'd like to get involved please do let me know, mproctor at redhat d0t com.

Tuesday, April 07, 2009

High performance human readable marshalling with MVEL

Thought I'd re-print this email to me from Mike Brock, the MVEL author:

This weekend, myself and Dhanji Prasanna from Google have firmed up an initial prototype implementation of MVBus; a new high-efficiency serialization framework built around MVEL, that is at least 4 times faster than XStream in the worst of scenarios.

It's a very impressive framework, inspired by an an idea by Mark Proctor.

It consists of an encoding engine with modular type plug-ins, that allows any Java object to be translated in compact MVEL code, which can then be executed natively by the MVEL interpreter to be turned back into a real object.

Here's an example of how it works:
// Create a simple POJO object
Person p = new Person("Mike", 30, new String[] { "Dorkus", "Jerkhead"});
p.setActive(true);

// Create another...
Person mother = new Person("Sarah", 50, new String[] { "Mommy", "Mom"});
mother.setActive(false);

// And another
Person father = new Person("John", 55, new String[] { "Dad", "Daddy"});
mother.setActive(false);

// Stick them together to make a somewhat complex graph
p.setMother(mother);
p.setFather(father);

// Create an MVBus encoding bus
MVBus bus = MVBus.createBus();

// Encode it!
String marshalled = bus.encode(p);
And here's what that 'marshalled' variable contains
org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{name="Mike",age=30,nicknames=new java.lang.String[] {"Dorkus","Jerkhead"},mother=org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{name="Sarah",age=50,nicknames=new java.lang.String[] {"Mommy","Mom"},active=false},father=org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{name="John",age=55,nicknames=new java.lang.String[] {"Dad","Daddy"},active=false},active=true}
This is completely native MVEL code that can be turned back into an Object simply by passing it to MVEL.eval(). And it's very fast. However, if this isn't pretty enough for you, the encoder has a nice pretty printer that can be turned on like so:
MVBus bus = MVBus.createBus(PrintStyle.PRETTY);  

String marshalled = bus.encode(p);
Which produces
org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{
name = "Mike",
age = 30,
nicknames = new java.lang.String[] {
"Dorkus","Jerkhead"
},
mother = org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{
name = "Sarah",
age = 50,
nicknames = new java.lang.String[] {
"Mommy","Mom"
},
active = false
},
father = org.mvbus.decode.MVBUSDecoder.instantiate(org.mvbus.tests.resources.Person).{
name = "John",
age = 55,
nicknames = new java.lang.String[] {
"Dad","Daddy"
},
active = false
},
active = true
}
... in all it's MVEL-ly glory.

Friday, April 03, 2009

BatchExecutor

One of the APIs that I really like in Drools 5.0 is the Command api and BatchExecutor combined with the Pipeline. Rule engines often have the concept of stateful or stateless sessions. Where stateful is the standard working memory that can be worked with iteratively over time. Stateless is a one off execution of a working memory with a provided data set and optionally returning some results with the session disposed at the end, prohibiting further iterative interactions. You can think of stateless as treating a rule engine like a function call with optional return results.

In Drools 4 we supported these two paradigms but the way the user interacted with them was different. StatelessSession used an execute(...) method which would insert a collection of objects as facts. StatefulSession didn't have this method and insert used the more traditional insert(...) method. The other issue was the StatelessSession did not return any results, the user was expected to map globals themselves to get results, and it wasn't possible to do anything else other than insert objects, users could not start processes or execute querries. Early versions of Drools 5 tried to address the results issue using the more traditional in/out parameters that others adopted, but still did not address starting processes or executing querries.

Finally with Drools 5.0 I managed to come up with an approach I was happy with that addressed all of these issues and more. The foundations for this is the BatchExecutor interface:
public interface BatchExecutor {
BatchExecutionResults execute(Command cmd);
}

public interface BatchExecutionResults {
Collection getIdentifiers();

Object getValue(String identifier);
}
Both the StatelessKnowledgeSession and StatefulKnowledgeSession implement this interface, creating consistency. The CommandFactory allows for commands to be executed on those sessions, only only difference being the StatelessKnowledgeSession executes fireAllRules() at the end before disposing the session. The current supported commands are:
  • FireAllRules
  • GetGlobal
  • SetGlobal
  • InsertObject
  • InsertElements
  • Query
  • StartProcess
  • BatchExecution
InsertObject will insert a single object while InsertElements will iterate an Iterable inserting each of the elements. What this means is that StatelessKnowledgeSession are no longer limited to just inserting objects, they can now start processes or execute querries. What you say, the method only allows for a single Command? That's Where the BatchExecution comes in, this is a composite command that takes a list of Commands and will iterate and execute each Command in turn. This means you can insert some objects, start a process, call fireAllRules and execute a query all in a single execute(...) call - much more powerful.

As mentioned the StatelessKnowledgeSession by default will execute fireAllRules() automatically at the end. However the keen eyed reader probably has already noticed the FireAllRules command and wondering how that works with a StatelessKnowledgeSession. The FireAllRules command is allowed and using it will disable the automatic execution at the end, think of using it as a sort of manual override.

So this is great, we've brought consistency to how StatelessKnowledgeSession and StatefullKnowledgeSession work and also brought in support for more than just inserting objects. What about result handling? Rather than using parameters, like my first attempt which always bugged me, these commands support out identifiers. Any command that has an out identifier set on it will add it's results to the BatchExecutionResults. Let's look at a simple example to see how this works:
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();

List cmds = new ArrayList();
cmds.add( CommandFactory.newInsertObject( new Cheese( "stilton", 1), "stilton") );
cmds.add( CommandFactory.newStartProcess( "process cheeses" ) );
cmds.add( CommandFactory.newQuery( "cheeses" ) );
BatchExecutionResults bresults = ksession.execute( CommandFactory.newBatchExecution( cmds ) );
QueryResults qresults = ( QueryResults ) bresults.getValue( "cheeses" );
Cheese stilton = ( Cheese ) bresults.getValue( "silton" );

So in the above example you saw how multiple commands where executed two of which populate the BatchExecutionResults. The query command defaults to use the same identifier as the query name, but it can also be mapped to a different identifier.

So now we have consistency across stateless and stateful sessions, ability to execute a variety of commands and an elegant way to deal with results. Does it get better than this? Absolutely we've built a custom XStream marshaller that can be used with the Drools Pipeline to get XML scripting, which is perfect for services.

I've mentioned the pipeline previously, it allows for a series of stages to be used together to help with getting data into and out of sessions. There is a stage that supports the BatchExecutor interface and allows the pipeline to script either a stateful or stateless session. The pipeline setup is trivial:
Action executeResultHandler = PipelineFactory.newExecuteResultHandler();

Action assignResult = PipelineFactory.newAssignObjectAsResult();
assignResult.setReceiver( executeResultHandler );

Transformer outTransformer = PipelineFactory.newXStreamToXmlTransformer( BatchExecutionHelper.newXStreamMarshaller() );
outTransformer.setReceiver( assignResult );

KnowledgeRuntimeCommand batchExecution = PipelineFactory.newBatchExecutor();
batchExecution.setReceiver( outTransformer );

Transformer inTransformer = PipelineFactory.newXStreamFromXmlTransformer( BatchExecutionHelper.newXStreamMarshaller() );
inTransformer.setReceiver( batchExecution );

Pipeline pipeline = PipelineFactory.newStatelessKnowledgeSessionPipeline( ksession );
pipeline.setReceiver( inTransformer );

The key thing here to note is the use of the BatchExecutionHelper to provide a specially configured XStream with custom converters for our Commands and the new BatchExecutor stage.

The above java code to create the BatchExecution is converted to java below, for added fun I've added parameters to the query.
<batch-execution>
<insert out-identifier="stilton">
<org.drools.Cheese>
<type>stilton</type>
<price>1</price>
</org.drools.Cheese>
</insert>
<query out-identifier='cheeses2' name='cheesesWithParams'>
<string>stilton</string>
<string>cheddar</string>
</query>
</batch-execution>
Executing is as simple as inserting the XML into the pipeline:
insert( inXml, resultHandler );

The pipeline also handles the results and marshalling back into XML:
String outXml = (String) resultHandler.getObject();
With the XML results looking something like:
<batch-execution-results>
<result identifier="stilton">
<org.drools.Cheese>
<type>stilton</type>
<price>2</price>
</org.drools.Cheese>
</result>
<result identifier='cheeses'>
<query-results>
<identifiers>
<identifier>stilton</identifier>
<identifier>cheddar</identifier>
</identifiers>
<row>
<org.drools.Cheese>
<type>cheddar</type>
<price>2</price>
<oldPrice>0</oldPrice>
</org.drools.Cheese>
</row>
<row>
<org.drools.Cheese>
<type>cheddar</type>
<price>1</price>
<oldPrice>0</oldPrice>
</org.drools.Cheese>
</row>
</query-results>
</result>
</batch-execution-results>

Pretty cool eh, so we've aligned a messaging format to our api and made it service friendly by integrating that with our pipeline.

Hopefully by now you can see why I'm so happy with this and glad I thought of doing this in time before releasing Drools 5.0, instead of using the parameters api. We will extend the CommandFactory to support all the methods for a StatefulknowledgeSession, all with XML marshalling using XStream. This will then form the foundations for rest/ws services in future releases of Drools.

Thursday, April 02, 2009

"Using Drools for Tracking and Situational Awareness" Added as a Lightning talk to the Drools Boot Camp

Adam Mollenkopf, from Fedex Custom Critical, will be joining us at the Drools Boot Camp to give a lightning talk titled "Using Drools for Tracking and Situational Awareness".

More details of the boot camp and schedule can be found here.

If you'd like to join us at the Boot Camp and do a lightning talk then please contact me mproctor at redhat d0t com

Wednesday, April 01, 2009

Drools Boot Camp Registration Page Now Open : San Francisco 1-7 June 2009

The Drools Boot Camp registration page is now open. If you are hoping to attend, please put your details there and send me an email, so that we can estimate and manage attendance. We only have spaces for about 20 or so people, so please do hurry. Registration wiki page can be found here, you will need to login to edit the page.

The Boot Camp is schedule for the 1-7 of June 2009 at the Hilton San Francisco, and includes both time tabled sessions and well as all day hacking with all the Drools team. The event is free and open to the public. Full details of the event can be found here.

A big thank you to Third Pillar for sponsoring the meeting room.

Drools Boot Camp introduces Lightning Talks (San Francisco June 2009)

Due to demand the Drools team are introducing lightning talks to the Boot Camp, following the Drools 5.0 primer on the Monday.

The Drools Boot Camp is open from the 1st to the 7th of June 2009, located at the Hilton Sanfrancisco - More details on the event can be found here. While the event is mostly about group hacking and open to the public, we also have a few time tabled discussions sessions which are detailed below:

Drools 5.0 Primer : Monday 1st of June 10.00 to 13.00
  • The new features in Drools 5.0 will be covered at an end user level. This includes all the drools projects, Guvnor, Flow, Fusion and Expert. This is suitable for anyone with minimal previous Drools experience who just want to know "what's new".
Community Lightening Talks : Monday 1st of June 13.30 to 14.30
  • 20 minute community lightening talks about their experiences with drools.
    • Tomasz Krywicki, from Sun, will talk about Drools in some of their software.
    • Adam Mollenkopf, from Fedex Custom Critical, will present "Using Drools for Tracking and Situational Awareness".
Drools 5.0 Guvnor Internals : Tuesday 10.00 to 12.00
  • The internals of Guvnor will be discussed and how all the parts come together and current issues and directions we wish to take the project. This is suitable for anyone with minimal previous Drools experience, but ideally you should be aware of GWT, JCR and Guvnor in general. This is targetted at people who wish to extend Guvnor with new features or re-use/embed existing aspects of Guvnor.
Drools 5.0 Domain Specific Workflow : Wednesday 10.00 to 12.00
  • We will show how Drools Flow can be extended for domain specific workflow, with a focus on the pluggable Work Items and Eclipse. We will also cover the pluggable workflow framework for customised execution behaviour, such as is used to provide OSWorkflow compatability. This is suitable for anyone with a java and eclipse background, ideally you should have some understanding of what Drools and especially Drools Flow is.
Drools 5.0 Advanced Engine : Thursday 10.00 to 13.00
  • This will be a deep dive for the technical on Rete enhancements. We will cover the asymmetrical Rete implementation, as compared to the traditional symmetrical approach, and how we enhanced it for event processing and workflow. This is targetted at experienced people, who already have an understanding of Rete and wish to understand the latest research and innovations - not for the feint hearted.

A big thank you to Third Pillar for sponsoring the meeting room.