Monday, December 01, 2008

Fluent Process API

A recent addition to Drools Flow allows users to create processes using what could be called a "fluent API". While it has always been possible to create processes using our graphical editor or the underlying XML, we do acknowledge that some people simply prefer creating process definitions using an API. The underlying example shows how easy it is now to create a simple "Hello World" example process using this API:

RuleFlowProcessFactory factory =
// header
.name("My process").packageName("org.drools")
// nodes
.action("java", "System.out.println(\"Hello World\");").done()
// connections
.connection(1, 2)
.connection(2, 3);
RuleFlowProcess process = factory.validate().getProcess();

Many thanks go out to salaboy for doing a large part of the work and adding the different factories to create the various types of nodes supported in RuleFlow. This also shows how easy it is to contribute to the Drools project if you want to: come join us at our #drools irc channel, describe what you want to do and we'll help you as much as possible and welcome contributions !



  1. I wouldn't call this api fluent just because it's chainable. A fluent api should read more like english.

    I believe a "connectedTo" operation to connect nodes during creation instead of an explicit connection(id,id) would help a lot. In the example it could/should replace done() - nodes with multiples in/out are probably a problem.

  2. True, we didn't really try hard to make readable English sentences. But this api is still targeted towards normal java developers, so then the question would be: what would the people who use this api prefer?

    Regarding the connections, we tried to find a simple solution that supports all use cases. But the good thing is we could support multiple ways. Could you give a more concrete example on how you would like it to work?

  3. Thanks for sharing the best information and suggestions, I love your content, and they are very nice and very useful to us. If you are looking for the best Bing Search Api, then visit SERP House. I appreciate the work you have put into this.

  4. I was just browsing through the internet looking for some information and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject. Bookmarked this page, will come back for more. verfahrensdokumentation