My First Book Published – Business Rules with JBoss Drools

The guys over at the official Drools blog beat me to the announcement, as I was waiting for it to published on Amazon, but now that it has, I’m happy to announce that after 12 months of pushing and shoving, I’ve finally got my first book , on Business rules and Workflow, out the door.

What, you’re still here? Well if it takes a bit more to convince you to buy it, here’s the info on the Business Rules and Workflow book direct from the publishers (Packt) own site. If you can’t wait, and want to dive right in, the code samples from the book are available on the Red Piranha 2 website.

JBoss Drools Business Rules
JBoss Drools Business Rules Capture, automate, and reuse your business processes in a clear English language that your computer can understand.

  • An easy-to-understand JBoss Drools business rules tutorial for non-programmers
  • Automate your business processes such as order processing, supply management, staff activity, and more
  • Prototype, test, and implement workflows by themselves using business rules that are simple statements written in an English-like language
  • Discover advanced features of Drools to write clear business rules that execute quickly
  • For confident users of Excel or other business software, this book is everything you need to learn JBoss Drools business rules and successfully automate your business.


Code download
Request a Review Copy
Send us feedback on this title
Ask a question about this title
Sample Chapter 4 Guided Rules with the Guvnor [2.0 MB]
Table of Contents
Book Details

Language English
Paperback 305 pages [191mm x 235mm]
Release date April 2009
ISBN 1847196063
ISBN 13 978-1-847196-06-4
Author(s) Paul Browne
Topics and Technologies Open Source, Java


A comprehensive, practical guide for business analysts and non-programmers to harnessing JBoss Drools Business Rules in your organization

In Detail

In business, a lot of actions are trigged by rules: “Order more ice cream when the stock is below 100 units and temperature is above 25° C”, “Approve credit card application when the credit background check is OK, past relationship with the customer is profitable, and identity is confirmed”, and so on. Traditional computer programming languages make it difficult to translate this “natural language” into a software program. But JBoss Rules (also known as Drools) enables anybody with basic IT skills and an understanding of the business to turn statements such as these into running computer code.

This book will teach you to specify business rules using JBoss Drools, and then put them into action in your business. You will be able to create rules that trigger actions and decisions, based on data that comes from a variety of sources and departments right across your business. Regardless of the size of your business, you can make your processes more effective and manageable by adopting JBoss Rules.

Banks use business rules to process your mortgage (home loan) application, and to manage the process through each step (initial indication of amount available, actual application, approval of the total according to strict rules regarding the amount of income, house value, previous repayment record, swapping title deeds, and so on).

Countries such as Australia apply business rules to visa applications (when you want to go and live there)—you get points for your age, whether you have a degree or masters, your occupation, any family members in the country, and a variety of other factors.

Supermarkets apply business rules to what stock they should have on their shelves and where—this depends upon analyzing factors such as how much shelf space there is, what location the supermarket is in, what people have bought the week before, the weather forecast for next week (for example, ice cream in hot weather), and what discounts the manufacturers are giving.

This book shows how you can use similar rules and processes in your business or organization. It begins with a detailed, clear explanation of business rules and how JBoss Rules supports them.

You will then see how to install and get to grips with the essential software required to use JBoss Rules. Once you have mastered the basic tools, you will learn how to build practical and effective of the business rule systems.

The book provides clear explanations of business rule jargon. You will learn how to work with Decision Tables, Domain-Specifi c Languages (DSL)s, the Guvnor and JBoss Integrated Development Environment (IDE), workflow and much more.

By the end of the book you will know exactly how to harness the power of JBoss Rules in your business.
Read the full Table of Contents for JBoss Drools Business Rules

What you will learn from this book

  • Understand the basics of business rules and JBoss rules with minimal effort
  • Install the required software easily and learn to use the Guvnor, which is a user-friendly web editor that’s also powerful enough to test our rules as we write them
  • Learn to write sophisticated rules and import the fact model into the Guvnor and then build a guided rule around it, which makes your web pages a lot clearer
  • Gain complete knowledge of what we can do with the Guvnor rule editor, and then use the JBoss IDE as an even more powerful way of writing rules, and automate processes for discounts, orders, sales, and more
  • Know the structure of the rule file through the example of a shipping schedule, which will help you with your own shipping schedule
  • Test your rules not only in the Guvnor, but also using FIT for rule testing against requirements documents; run unit tests using JUnit for error-free rules and interruption-free services
  • Specifically, non-developers can work with Excel spreadsheets as a fact model to develop business processes without learning any other new technology
  • Work with DSLs (Domain-Specific Languages) and rule flow to make writing rules easy; which makes staff training quicker and your working life easier
  • Deploy your business rules to the real world, which completes your project successfully, and combine this into a web project using the framework of your choice to provide better services
  • Benefit from concepts such as truth maintenance, conflict resolution, pattern matching rules agenda, and the Rete algorithm to provide advanced and faster business systems so that staff efficiency is maximized

Chapter 1, Drooling over JBoss Rules. This chapter gives you a good platform to understand business rules and JBoss rules. We look at the problems that you might have (and why you’re probably reading this book). We look at what business rule engines are, and how they evaluate business rules that appear very simple and how they become powerful when multiple rules are combined.

Chapter 2, Getting the software, deals with installation. This chapter explains setting up Java, setting up Business Rule Management System (BRMS)/Guvnor running on the JBoss App Server, setting up Eclipse, and installing the Drools Plug-in. It also details the installation of the Drools examples for this book and the Maven to build them.

Chapter 3, Meet the Guvnor, deals with writing our rules using the ‘Guvnor’. Guvnor is the user-friendly web editor that’s also powerful enough to test our rules as we write them. We take up an example to make things easier. Then we look at the various Guvnor screens, and see that it can not only write rules (using both guided and advanced editors), but that it can also organize rules and other assets in packages, and also allow us to test and deploy those packages. Finally, we write our very first business rule—the traditional ‘Hello World’ message announcing to everyone that we are now business rule authors.

Chapter 4, Guided Rules with the Guvnor. This chapter shows how to use the Guvnor rule editor to write some more sophisticated rules. It also shows how to get information in and out of our rules, and demonstrates how to create the fact model needed to do this. We import our new fact model into the Guvnor and then build a guided rule around it. Finally we test our rule as a way of making sure that it runs correctly.

Chapter 5, From Guvnor to JBoss IDE. This chapter pushes the boundries of what we can do with the Guvnor rule editor, and then brings in the JBoss IDE as an even more powerful way of writing rules. We start by using variables in our rules example. Then we discuss rule attributes (such as salience) to stop our rules from making changes that cause them to fi re again and again. After testing this successfully, we look at text-based rules, in both the Guvnor and the JBoss IDE, for running ‘Hello World’ in the new environment.

Chapter 6, More Rules in the jBoss IDE. This chapter looks again at the structure of a rule fi le. At the end of this chapter, we look at some more advanced rules that we can write and run in the IDE.

Chapter 7, Testing your Rules. This chapter explains how testing is not a standalone activity, but part of an ongoing cycle. In this chapter we see how to test our rules, not only in the Guvnor, but also using FIT for rule testing against requirements documents. This chapter also explains Unit Testing using JUnit.

Chapter 8, Data in Excel, Rules in Excel. This chapter explains how to use Excel Spreadsheets (cells and ranges) as our fact model to hold information, instead of the write-your-own-JavaBean approach we took earlier. Then we use Excel spreadsheets to hold Decision tables, to make repetitive rules easier to write.

Chapter 9, Domain-Specific Languages [DSL] and rule flow. This chapter aims to make our rules both easier to use, and more powerful. We start with DSLs—Domain-Specifi c Languages. This chapter follows on from the ‘easy to write rules’ theme from the previous chapter and also discusses both ruleflow and workflow. It would be great to draw a workfl ow diagram to see/control what (groups of) rules should fi re and when. Rule flow gives us this sort of control.

Chapter 10, Deploying rules in real life. This chapter shows you how to deploy your business rules into the real world. We look at the pieces that make up an entire web application, and where rules fit into it. We see the various options to deploy rules as part of our application, and the team involved in doing so. Once they are deployed, we look at the code that would load and run the rules—both home-grown and using the standard RuleAgent. Finally we see how to combine this into a web project using the framework of your choice.

Chapter 11, Peeking under the covers. This chapter looks at what happens under the cover by opening up the internals of the Drools rule engine to understand concepts such as truth maintenance, confl ict resolution, pattern matching, and the rules agenda. In this chapter, we explore the Rete algorithm and discuss why it makes rules run faster than most comparable business logic. Finally we see the working memory audit log and the rules debug capabilities of the Drools IDE.

Chapter 12, Other Drools features. This chapter deals with the other advanced Drools features that have not yet been covered. This includes Smooks to bulk load data, Complex Event Processing, and Drools solver to provide solutions where traditional techniques would take too long.

Approach

This book takes a practical approach, with step-by-step instructions. It doesn’t hesitate to talk about the technologies, but takes time to explain them (to an Excel power-user level). There is a good use of graphics and code where necessary.

Who this book is written for

If you are a business analyst – somebody involved with enterprise IT but at a high level, understanding problems and planning solutions, rather than coding in-depth implementations – then this book is for you.

If you are a business user who needs to write rules, or a technical person who needs to support rules, this book is for you.

If you are looking for an introduction to rule engine technology, this book will satisfy your needs.

If you are a business user and want to write rules using Guvnor/JBoss IDE, this book will be suitable for you.

This book will also suit your need if you are a business user and want to understand what Drools can do and how it works, but would rather leave the implementation to a developer.


Author(s)

Paul Browne
Paul Browne’s first job was selling computers in France and things went steadily downhill from there. He spent millons on behalf of a UK telephone company’s procurement department and implemented direct marketing for a well-known Texan computer maker before joining the IT department of a company that builds bright red tractors and other seriously cool machines.

Paul then embraced his techie side (he was writing games in machine code from the age of 11) and started a consultancy that used IT to solve business problems for companies in the financial and public sectors in Ireland, UK , Belgium, and New Zealand. Eight years later, he now works with an Irish government agency that helps similar software companies to grow past their initial teething pains.

More formally, Paul has a bachelor’s degree in Business and French from the University of Ulster, a master’s degree in Advanced Software from UCD Dublin, a post-grad qualification in Procurement from the Chartered Institute of Procurement and Supply (UK), and will someday complete his ACCA financial exams.

Paul can be found on LinkedIn at http://www.linkedin.com/in/paulbrowne , and via the Red Piranha (Business knowledge) project at http://code.google.com/p/red-piranha/ .

How to combine Workflow and Business Rules – in 5 easy steps

Tom has a good post on the jBPM (JBoss workflow) community day held at the Guinness brewery in Dublin. Warning – slides may contain pictures of people drinking beer.

Drools jPBM Business rules presentation

How to combine (jBPM) Workflow and (Drools) Business Rules – here’s the summary. Slideset is available on this blogpost.

  • Workflow (e.g. JBoss jBPM) is great – it allows you to take spaghetti code and draw it as a workflow diagram (flowchart) so that it can be reviewed by the business (the nice people who pay our wages). You then attach standard (Java) actions to these steps.
  • Only problem is when you come to a decision node (the one circled in red below): How do you decide to go left or right (in the workflow)? Normally this is coded in Java – good for us, but hidden from those nice business people (which means that this is more room for errors-in-translation).
  • Business Rules allow you to keep those decision making rules in Plain English: When something is true , then do this. That’s it. The rule engine does most of the hard work.
  • Integrating Workflow and Rules is easy. Use JBoss Seam (link) or do it by hand (link). And it works on non-JBoss web / app servers such as Websphere, Oracle Application Server, Tomcat and Weblogic.
  • Repeat x6 : Use workflow and rules. Use workflow and rules …

Simple Workflow

In a maybe related development, Tom Baeyens is now using strangely Rules-y like examples over on his workflow blog ….

JBoss Business Rules and jBPM Workflow presentation – Dublin

Update: Shortcut to slides (pdf, with notes following) here.

Speaking at the JBoss jBPM community day tomorrow and I’m nervous. I’m nervous because I’m standing up and talking to a group of people that really know their stuff about JBoss workflow. And talking about a project (JBoss Business rules) which has a friendly rivalry with it.

jbpm logo

So here goes

  1. Slides in Powerpoint emailed to myself (check)
  2. Slides in PDF available online (check).
  3. Slides in Open Office on laptop ready for presentation (check)

Drools Logo
More details on the jBPM wiki if you’re interested in attending the event. Anybody give odds on the laptop bluescreen again (like what happened at the Irish Java Technologies Conference)? It’s not what happens, it’s how you deal with it.

JBoss workflow invading Dublin (Free Community Conference)

I’m not going to explain what workflow is as I’ve probably blogged enough about it already. But the JBoss Workflow (jBPM) guys are coming to Dublin on June 6th. If you’re into workflow (and if you’re doing any sort of software for large business you should be) then this is a do not miss event and we’re privileged to have it in Ireland.

The JBoss workflow guys are dream guests. They just asked for a couple of venue suggestions and they finally went for the Guinness Hopstore where Barcamp ran last year. Next thing we got was an email saying that the JBoss Workflow event was go. So for the benefit of people flying into Dublin, here’s the information we gave on where to stay and things to do if you’re making a weekend of it.

(More information on the event on Tom Baeyens Blog)

Workflow

How to get there

Dublin is pretty well served by direct flights from Europe and the US. Aer Lingus and Ryanair are the two biggest airlines flying into Dublin – but there are plenty more (list at FlightMapping.com).

Things to do

  • Tour of Guinness brewery and visit the Gravity bar (one of the highest in Dublin)
  • Dublin Pub Tour and general social scene (it’s a coincidence that the first 2 items are drink related!)
  • Tour of Scenic Wicklow Mountains and Glendalough
  • Liffey River tour by boat
  • Dublin Bus tour – including it’s Georgian buildings and coastline
  • Newgrange – 2000 years older than the pyramids, in the stunning Boyne valley
  • Windsurfing , Kayaking or Rock climbing in Viking Carlingford Fjord.
  • Trinity College Dublin, 400 years old university , right in the city centre including the 1000 year old ‘Book of Kells’
  • For the more curious , Belfast is 2hrs away by express train in Northern Ireland.
  • Get lost in Phoneix Park, the worlds largest city centre park.

Places to Stay

I don’t tend to say in Dublin hotels too much (!) but the following I know are reasonably good value (and quiet / clean)

  • 3 of the Jury’s Inn (Christchurch is just down the road from the event location, but the IFSC and Parnell Street are also good)
  • Academy hotel is ok, if slightly more expensive , if you’re stuck.
  • If you want an airport location (about 20 mins / 20 Euro Taxi from the city centre) the Premier Inn chain are pretty good.
  • Hotel Isaacs is budget but decent , central and near the main bus / train stations.
  • Morgan hotel is where the presenters were put up for the Dublin Java conference. Central but Slightly more pricey.

For people from the community, there’s also plenty of ‘budget’ backpacker type accommodation.

You need to go to a self help group – Rules and Workflow

Picture the scene: a self help group meeting, plastic chairs arranged in a circle. Sitting on the chairs are an assortment of (mainly) men in their 20’s or 30’s. One plucks up the courage and mumbles ‘Hello, I’m Paul , and I’ve been writing bad Java code for 10 years‘.

When I got into Java I was using JSP for everything – HTML, talking to databases, doing workflow – anything I could get my hands on. I was young and I didn’t know what I was doing. Even after I got treatment based on EJB, Spring and Hibernate, I still feel that there is a void at the centre of my coding life‘.

Rule Engine Logo

I fell in with a bad crowd. Business types with suits and violin cases. They said they’d pay me good money if I built them something. Now they don’t believe that it works – it’s all techie stuff to them. Those boys are going to play rough if I can’t make them understand the code. What can I do?

There was silence for a while. Then the group leader said

It’s a tough one. Does anybody have any suggestions?

Read the full text of the O’Reilly Mini-Article here.

Idiots guide to Service Orientated Architecture (SOA)

Lost in the hype around Service Orientated Architecture (SOA) is the fact that the idea is really really simple. It’s all based on the idea that most applications (and that includes websites) are built either to be used by people , or used by computers. The pictures below (a free preview from the Enterprise Java Briefing) show what I mean.

In a ‘normal’ application, such as a online banking website, we need to remember what the user did last (are they logged in, what account are they looking at, are they in the middle of making a payment). If we didn’t , the user would get annoyed about having to repeat themselves every step of the way. It would also make for pretty complicated screens, to allow the user to enter all the information in one go. Instead , we allow the user to enter information in several steps, and remember where there are each time.

Soa Client

In an application designed to be used by computers, we don’t have to worry about this. We can force the computer to give us all the information required all in one go – username , password, bank account to take money from , bank account to give money to, date to execute transaction. For a computer , this is actually easier ; we make one call to our banking service and we are told it has succeeded or failed. It’s also easier for us to build our service:

  • Each service (transfer money, book flight , execute share trade) only does one thing.
  • Because each service ‘forgets’ after each call, we don’t need to worry about trying to remember what we were doing before.
  • Because we have no memory, services are very scalable; we can make several copies of the same service and put them in a pool. Any client can talk to any service – no waiting for a particular server to become available.

Soa Service

So that’s Service Orientated Architecture (SOA) : programs that do one thing (a bit like a function call to a method) exposed that other computers can call. So what’s the big deal? Like all good ideas , a simple concept goes a long way.

Take a look at the picture below. It’s like a Visio diagram, but in fact it’s drawn by the Eclipse Based JBoss IDE. It shows a workflow for an online commerce store – pretty easy to understand. This example uses JBoss Java Business Process Managment (jBPM), but companies such  Tibco, Cape clear and Oracle BPEL have similar products.

soa workflow

Here’s the clever bit; each of these steps is executed by one of the services that we talked about earlier. This means that if the business process changes (and it will), then all you have to do is re-arrange the diagram ; little or no coding changes should be required.

This abilility to mix , match, combine and remix services leads us to a lot of other good things (and we’re only scratching the surface here).

  • Because our services don’t have to run on the same machine, we can use SOA to create a distributed application. This is the concept behind the BPEL (Business PRocess Engineering Language)
  • Services tie well to Ajax and Web 2: Our Ajax web page or portlet can call as many services as it requires to get the job done (it’s one of the reasons Tibcom is sponsoring the open source DWR project)
  • We can call many services at once. If these this service calls are xml based ,or we send these calls as a message then we can filter, duplicate, pass and other distribute these calls as we set. These are the ideas behind Apache Synapse, Apache Servicemix and the  Enterprise Service bus (ESB) in general.

What do you think? Is SOA useful , or over hyped?

related posts

Grabbing people's brains and shoving them into a PC

It didn’t go down too well when an elderly relative asked me over Christmas ‘what exactly do you do?’. After fobbing him off with the usual ‘something in computers’, he was shocked to find out that I spend most of my time ‘Grabbing people’s brains and shoving them into a PC’.

This kind of blog-related-violence is normally associated with Twenty-Major (Warning , Parential Guidance required , unless you’re over 80), so before you call the police , let me explain.

Look at your hands. Unless they’re scarred and calloused (from the weekend’s DIY) the chances are that you work in the knowledge economy. You could work for a Bank , Insurance company, Legal company or be a medical professional but most of your work consists of one thing:  You push pieces of paper around that have some magical value.
Or you would push pieces of paper around if it hadn’t all been computerised in the last 10 years. Now you swap files and emails to get things done.  And you swear on a regular basis when the computer can’t find the information you’re looking for, or someone doesn’t understand the email you sent them. But the important bit, the information processing,  still remains in your brain.
Red Piranha Logo

Which brings us to Red-Piranha (site update in progress) and the shoving of people’s brains into a computer. While we can copy an MP3 music file (with Adam’s and Bono’s imagination in it) and send it around the world, but we can’t photocopy your brain. We don’t want all of it, just the part that gets the magical value-added work done. The bits about drinking beer and playing volleyball on the beach we’ll quite happily leave with you.

So this is what Enterprise Web 2.0 is all about : getting the computer to take a load off your brain so that you’ll have more time to spend on the beach drinking beer. Chapter 3 (draft) of our Enerprise Web book has just been put online, which shows you exactly how to do this.