Activiti 5.x Business Process Management Beginner’s Guide review

I was asked by Packt to review their newly published book Activiti 5.x Business Process Management Beginner’s Guide. Authored by Dr. Zakir Laliwala and Irshad Mansuri, the book aims - as the title suggests - to provide those new to Activiti a starting point for learning to use the framework. In that sense, this book is a welcome addition to Tijs’ Activiti in Action book and the already quite excellent user guide provided with the framework and maintained by the team and community.

The book is filled with examples, lots of screenshots to follow along with and covers quite some ground from very basic processes to integrating Activiti with Drools, Esper or running it on Apache Karaf. The authors get straight into the nitty-gritty details and show you how to model, deploy and run BPMN 2.0 processes using the Activiti framework.

Even so, upon finishing the book, I can’t shred an overall sense of disappointment. As much as I appreciate the intent of writing a no-frills, down-to-earth, practice-oriented guide, the quality with which it is written is simply under par. I regularly found myself puzzled with either the lack of explanation or the actual explanation of some concepts when one was provided. Let me explain that with some examples.

First of all, the editing is not good enough for a book like this. I don’t think you can really blame the authors for that, as I suspect English is not their first language. After editing, there are just too many mistakes, half sentences and poor paragraphs with duplications to look past. I can deal with a bit of roughness here and there, but at a certain point it becomes annoying.

The general build-up in the book might be fine if you are following along but not really thinking ahead too much, but it’s actually very illogical if you look more closely. There are concepts used that haven’t been explained, such as the use of BPMN constructs without proper introduction and they have been using Activiti’s process engine for 4 chapters before it’s properly described at all. How chapter 8 ever ended up before chapter 9 is unclear. I don’t understand why you can’t introduce a couple of BPMN concepts in one chapter, use them in an example and then add new ones in order to explain other features in subsequent chapters. It seems the logical way to guide a reader into using the framework.

I want to point out that I understand the authors have chosen to avoid long introductions and theoretical discussions that underpin most BPM or Activiti concepts. However, if you don’t even indicate that and set up no conceptual framework at all (which would only really cost you couple of sentences), you leave the reader with no background or pointers for more information as to what you’re doing, why it’s even relevant and especially whether there are alternative ways to do things. Which in many cases, for the examples in this book, there are. Add to that the fact that the option shown is generally not the one you would use in any serious process implementation and I fear people might run with these examples and get themselves into trouble. Again, with context this is OK, but this book provides no such disclaimers and the guides are written as if this is actually the one and correct way to achieve things.

You will find no best practices, methodological guidance or implementation recommendations in this book - it’s not the aim of the book. If you’re not looking for that, this is obviously fine because you get the details and examples without that getting in the way of all the fun Activiti has to offer. However, I feel that topics like BPMN 2.0, unit testing of processes and architectural positioning of a process engine in its environment warrant at least a basic introduction of terminology, intent and guiding principles for a book to provide you with any kind of foundation for learning how to implement business processes - with any framework.

Quite surprising to me is the omission of any guidance on how to integrate services that actually perform business logic in your business processes. ScriptTasks, Listeners, etc. are used here and there, but the book contains no elaborated examples of using BPMN’s ServiceTask and configuring the various invocations Activiti supports for Java classes, delegates resolved from expressions, etc. You will need that in almost any business process.

Where explanations are given, they are often very brief, (partially) incorrect or without nuance. This is regrettable because for a beginner, this sets you off on the wrong foot. I could mention quite a few, but this really should have been caught in technical reviews.

The examples provided often bypass important details for the reader. For instance, at some point a start form is used for a process and this is shown in a screenshot. Later on, a unit test is created that uses a map to provide the same data in the form of variables to a process instance which is started in the test. Great, because you often test the process by simulating a certain set of input from a user. The problem is, that the previous explanation is mine. The authors do not link the two to explain what’s going on. In fact, the whole principles of process definition vs process instance, variables linked to a process instance, etc. are not detailed anywhere in the book even though they are critical to working with Activiti.

The balance of information is off in certain chapters. A lot of time is taken to explain how to configure the mail server and use the MailTask, but this is an Activiti-specific construct, not a BPMN one. On the other hand, the basics of BPMN are scattered all over the book, if addressed at all. There is a lot of information on suspending and activating process definitions, but none on asynchronous continuations or jobs and transactional boundaries within Activiti. Which do you think you would need first? Also, a casual remark that you can delete a task using the TaskService is not only irrelevant for the intended reader, but it’s also questionable to suggest such an option exists without explaining when it should or should not be used, as mistakes could lead to very tricky situations to resolve. No attention is paid to the actual behaviour of constructs such as inclusive gateways or call activities, even though they are used in the examples. If you want to help people get started with Activiti, you need to explain the various constructs available and the purpose they serve in a process, or you should not use them and refer to further reading for the ones omitted.

Another example is the rather poor display of testing processes. I’m a proponent of rigorous automated testing of business processes. In my mind, this is one of the areas in which Activiti excels in terms of support. So I’m glad to see when this is applied to examples with Activiti. However, it’s obvious from the example code that the purpose of unit testing is not well-defined before it is used. There’s no point in starting a process instance, expecting it to run up to a UserTask and then querying Activiti’s TaskService for exactly one UserTask and assert that the task’s name matches the modelled one. That test is useless and fragile. If you decide to change the name of the task to more accurately reflect the business function of the task, the test will fail. If you run the test in parallel with others that do the same, it will sometimes fail because there isn’t just one UserTask open for claiming. But there’s no reason it should. Instead, you want to test the flow is correctly configured and reacts properly to orchestration data. So you query for tasks in the process instance you started and that have the expected task definition id, so you know it’s an instance of the exact task you expect to have been created at that point in your process instance. Then you can assert that the result’s not null, that the proper assignment has been completed, etc on that task. Also, you need not copy the BPMN file to the test resources to test it. Come to think of it, you really shouldn’t.

Another strong point when using Activiti is that the framework lends itself for integration in many different types of applications by allowing you various ways to construct a configuration and launch a ProcessEngine based on that configuration. This enables you to use Activiti in almost any Java application, whether embedded or standalone, on an EE application server, within a Spring context or on an OSGi framework. However, here it’s presented as if Activiti Explorer is the one and only way you run Activiti. Even when Apache Karaf is used as the runtime, it’s used to deploy the Explorer war file and run Activiti from within that context. Which holds no real benefits at all, because it gets you no further towards leveraging the services environment provided by the OSGi framework.

I would have liked to see an explanation of the fact that you can use any UI application you want to perform tasks with Activiti, by using form keys and the TaskService. In many environments where Activiti is used, there will be a need to use a custom UI solution. Here, Activiti Explorer is used for all interactions with users, as if it were the only way. For example purposes, this is a great way to get started, but before you start investing a lot of time into defining loads of screens in form properties, which is an Activiti-specific extension to BPMN, you should figure out whether a) Explorer is an application you really want users to use in production at all and b) whether you want your UI to be aware of such Activiti extensions in order to render screens. I’m in the a) probably not and b) definitely not camp.

If it were up to me, chapter 8 would not be part of this book. There is too little room to explain what’s going on and that’s exactly what happens in the guides: Activiti gets started in combination with some other framework or application and then the following one is shown without going any deeper into applications of what was just done. Especially the Liferay and OSGi examples suffer from this lack of any detail. Getting the process engine to run on these is step 1. The really interesting stuff starts from there, but is nowhere to be found.

If you’re looking for a very practical introduction and some samples of achieving the basics with Activiti, this book might come in handy. You can use the examples to showcase some of the functionality Activiti supports and show how easy it is to get a simple process working. However, all in all, I feel this book cuts too many corners to recommend it to people who need to learn how to use Activiti in a way that is future-proof and production ready.