Tài liệu Activiti in Action: Executable business processes in BPMN 2.0 - Pdf 10

MANNING
Tijs Rademakers
FOREWORDS BY Tom Baeyens
AND Joram Barrez
Executable business processes in BPMN 2.0
IN ACTION
www.it-ebooks.info
<definitions>
<process>
<startEvent/>
<sequenceFlow/>
<endEvent/>
</process>
</definitions>
Activiti Designer
Activiti Engine
Process implementation
Web forms
Ta sk s
Jobs
Processes
WS
REST
DB
Activiti provides a complete BPM solution, starting with the Activiti Designer to draw your business processes using BPMN.
The XML output of the Activiti Designer is deployed to the Activiti Engine that runs the process definition. The Activiti Engine
executes automated steps, like calling a web service, as well as manual steps that involve people and web forms.
www.it-ebooks.info
Activiti in Action
www.it-ebooks.info
www.it-ebooks.info

20 Baldwin Road Copyeditor: June Eding
PO Box 261 Proofreader: Nermina Miller
Shelter Island, NY 11964 Typesetter: Gordan Salinovic
Cover designer: Marija Tudor
ISBN 9781617290121
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 17 16 15 14 13 12
www.it-ebooks.info
v
brief contents
PART 1 INTRODUCING BPMN 2.0 AND ACTIVITI 1
1 ■ Introducing the Activiti framework 3
2 ■ BPMN 2.0: what’s in it for developers? 19
3 ■ Introducing the Activiti tool stack 32
4 ■ Working with the Activiti process engine 49
PART 2 IMPLEMENTING BPMN 2.0 PROCESSES WITH ACTIVITI 85
5 ■ Implementing a BPMN 2.0 process 87
6 ■ Applying advanced BPMN 2.0 and extensions 112
7 ■ Dealing with error handling 146
8 ■ Deploying and configuring the Activiti Engine 169
9 ■ Exploring additional Activiti modules 193
PART 3 ENHANCING BPMN 2.0 PROCESSES 223
10 ■ Implementing advanced workflow 225
11 ■ Integrating services with a BPMN 2.0 process 260
12 ■ Ruling the business rule engine 286
www.it-ebooks.info
BRIEF CONTENTS
vi
13 ■ Document management using Alfresco 311
14 ■ Business monitoring and Activiti 340

2
BPMN 2.0: what’s in it for developers? 19
2.1 Taking a closer look at BPM 20
Walking around the BPM life cycle 21
2.2 Evolution to BPMN 2.0 22
Wasn’t there a standard called WS-BPEL? 22

And then there
was BPMN 2.0 23

Getting your head around all the BPMN 2.0
constructs 24
2.3 Introducing BPMN 2.0 from a developer’s viewpoint 26
High-level modeling with BPMN 2.0 26

Detailed process modeling 28
2.4 Summary 31
3
Introducing the Activiti tool stack 32
3.1 Working with the Activiti Modeler 33
Installing the Activiti Modeler 33

Modeling processes with the
Activiti Modeler 34
3.2 Adding technical details with the Activiti Designer 36
Getting up and running with Activiti Designer 36

Designing a
process from scratch 37


the past with the HistoryService 67
4.3 Using plain Java to do BPM 72
Java service task with class definition 73

Introducing asynchronous
behavior 75

Java service task with class definition and field
extensions 76

Java service task with method and value expressions 78
www.it-ebooks.info
CONTENTS
ix
4.4 Using Spring with Activiti 79
Creating a generic Spring configuration for Activiti 79
Implementing a Spring-enabled unit test for Activiti 81
4.5 Summary 84
PART 2 IMPLEMENTING BPMN 2.0 PROCESSES
WITH ACTIVITI 85
5
Implementing a BPMN 2.0 process 87
5.1 Introducing a real business process 88
Analyzing the loan request process 88

Taking a process model to
an XML process file 89
5.2 Developing script and service tasks 90
Scripting in the Activiti Engine 90


Applying advanced BPMN 2.0 and extensions 112
6.1 Using BPMN 2.0 subprocesses 113
Background to BPMN subprocesses 113

Implementing embedded
subprocesses 114

Implementing standalone subprocesses 120
6.2 Working with BPMN 2.0 parallel gateways 126
Implementing a process with a parallel gateway 127

Testing a
process with a parallel gateway 129
6.3 Adding a JPA extension to your process 130
Modeling a process with a database entity 131

Implementing a process
with JPA extensions 132

Testing a process with JPA extensions 136
www.it-ebooks.info
CONTENTS
x
6.4 Using execution and task listeners 137
Modeling a process with execution and task listeners 138
Implementing execution and task listeners 139

Testing the event
stack list 142
6.5 Summary 144

Embedding the Activiti Engine in a Java application 170

Using
a standalone Activiti Engine instance 172

Choosing between the
deployment options 175
8.2 Using a Spring-managed Activiti Engine 176
Creating a process engine from a config file or Java 176

Creating
a process engine from a Spring configuration 177
8.3 Configuring the Activiti Engine 181
Basic configuration overview of the Activiti
Engine 181

Configuring the Activiti Engine database
options 182

Exploring other configuration options 184
8.4 REST communication with the Activiti Engine 185
Introducing the Activiti REST API 185

Implementing a new
Activiti REST service 187
8.5 Summary 192
www.it-ebooks.info
CONTENTS
xi
9

10.3 Implementing the BPMN 2.0 multi-instance activity 246
Configuring a multi-instance activity 246

Implementing a
multi-instance embedded process 247
10.4 Custom form types and external form rendering 253
Implementing a custom form type 253

Using external form
rendering 257
10.5 Summary 259
11
Integrating services with a BPMN 2.0 process 260
11.1 Invoking services from a BPMN 2.0 process 261
Calling services via a service task 261

Separating process logic
from integration logic 262
11.2 Using the BPMN 2.0 web service task 264
11.3 Integrating with Apache Camel 268
Introducing Apache Camel 268

Sending and receiving process
messages with Apache Camel 272
www.it-ebooks.info
CONTENTS
xii
11.4 Integrating with Mule ESB 276
Introducing Mule ESB 276


12.4 Creating a web-based rule editor 307
Introducing flexibility with a custom rule authoring application 307
12.5 Summary 309
13
Document management using Alfresco 311
13.1 Introducing Alfresco Community 312
Installing Alfresco Community 312

Introducing Activiti
integration in Alfresco 315
13.2 Using CMIS to store and retrieve documents 320
Retrieving folder content from Alfresco using CMIS 320

Storing
a new document version 323
13.3 Adding documents to a BPMN 2.0 process definition 326
Working with task and process instance attachments 326
Implementing a document-aware process definition 328
Deploying and testing the document-aware process definition 336
13.4 Summary 338
14
Business monitoring and Activiti 340
14.1 Monitoring business processes 341
Introducing business activity monitoring (BAM) 341
Introducing complex event processing (CEP) 343
www.it-ebooks.info
CONTENTS
xiii
14.2 Meeting the Esper framework 345
Kick-starting Esper 345

15.2 Dealing with process versioning 381
15.3 Understanding the job executor 384
15.4 Building an administrator dashboard 386
15.5 Summary 392
appendix A Working with the source code 395
appendix B BPMN 2.0 supported elements in Activiti 398
index 418
www.it-ebooks.info
www.it-ebooks.info
xv
foreword by tom baeyens
Business processes represent the core functions of an organization. If these core
functions are implemented inefficiently, a company gives its competitors an easy
advantage. Business Process Management (
BPM) is nothing more than ensuring that
an organization is run well and remains in good shape. For small companies, a single
person might be able to oversee everything that is going on and deal with situations
as they occur. But when companies grow larger and processes expand, it’s harder to
maintain control. Work is delegated, people start optimizing their own responsibili-
ties, and an overview can quickly get lost. Over the long run, constant monitoring
and improving of business processes are what separates good organizations from
excellent ones.
One aspect of managing business processes is automation. Despite big advance-
ments in software technology in the last decade, building custom software to support
business processes remains expensive for enterprises.
Traditional
BPM Systems (BPMSs) have attempted to simplify the creation of soft-
ware for monitoring business processes. The biggest advantage of BPMSs is that they’re
based on flowchart diagrams. Business managers and technical team members can
understand these diagrams, which helps bring communication of requirements to a

the old problem. Initially, the focus was on state machines, but eventually we con-
structed an engine to match the way business people and developers collaborate. We
designed the engine in such a way that it would allow business people to define the
graphical flow of the process and, at the same time, give developers the opportunity
to bind program logic inside the process flows. In addition, the engine was light-
weight and integrated easily into any Java environment. The result was what we call
embeddable
BPM.
BPMN is a recent standard that has emerged from a long list of predecessors in the
BPM space. It describes the shapes and connections for drawing business-process dia-
grams as well as their meanings and file formats. BPMN is different because of its clear
focus on the business side and process modeling, whereas earlier standards focused
more on the technical aspects.
In this book, Tijs has included concrete instructions for developers, technical man-
agers, and business analysts to start building
BPMN process solutions with Activiti. The
book includes a comprehensive overview of the Activiti framework, the Activiti
Engine, and
BPMN. But Tijs goes beyond the basics and describes how to integrate
these with a rule engine and web-based services.
The reader will get a thorough understanding of
BPM technology as it is applied in
today’s enterprise environments. This is definitely the most practical guide to BPMN
using Activiti as the engine.
TOM BAEYENS
ACTIVITI AND JBPM FOUNDER
CHIEF BPM ARCHITECT, ALFRESCO
www.it-ebooks.info
xvii
foreword by joram barrez

subsequently to help build Activiti at Alfresco.
Why the switch? The answer is simple. There was no room for an Apache-licensed
engine at
JBoss at that time, but we knew that an Apache license was crucial due to the
advent of the BPMN 2.0 standard. If we weren’t going to do it, someone else would.
Putting all our experiences together—what worked, what didn’t work, and what
rocked—we started to build a
BPMN 2.0 engine at the beginning of 2010, an engine that
would do exactly what I started my story with: improve communication between those
who need software solutions and those who build software by using flowchart-like dia-
grams. Expressing how your business works with diagrams is hard, but it is worth the
effort. Visualization is a powerful tool and, in the past, I often saw clients change their
way of working after seeing how the different steps connected. The
BPMN 2.0 standard
is of great value here. It may seem simplistic, but by defining how certain shapes have
specific meanings, not only can you visualize your workflows, you can find others in the
industry who speak the same language. The fact that version 2.0 also includes execution
semantics adds the next level of power: not only do the diagrams become standardized,
but now you can switch the engine that’s executing the diagrams with any
BPMN 2.0–
compliant engine—not that there is any reason to switch from Activiti, of course!
As a Java developer, I used to loathe
BPM suites—big black boxes that cost tons of
money to produce pictures. Every sane developer understands that pictures will never
make it into stable, performant software. That is why you will love Activiti: it is built
with benefits for business users in mind, without forgetting the developers. All the
code is open source—if something bothers you or isn’t clear, you can join our discus-
sions on the forum. Activiti in its simplest form is a library, a
JAR, one among many,
embeddable in every Java project, be it EE, Spring, or OSGi. With Activiti, you write

source project, which was in stealth mode at that time (early 2010). When the first
alpha version of Activiti was released, I told myself I had to contribute to that project,
one way or another.
A piece that was missing in the first stages of the Activiti project was an Eclipse
plug-in. I had some email conversations with Tom about contributing the plug-in to
Activiti. We met and he told me that his goal was to disrupt the process engine space
with the Activiti project. My enthusiasm grew even more and I offered my time to start
working on a first version of the Activiti Designer. Together with my former col-
leagues, Tiese Barrell, Yvo Swillens, and Ron van Liempd, we were able to deliver a
first version within a couple of months.
As we became part of the Activiti developer community, my hands were itching to
start writing a book about Activiti. I felt that a great open source process engine would
need a detailed book to describe all the possibilities and potential it offers. Manning
was eager to publish a book about Activiti, and, together with Ron, we started writing
in the autumn of 2010. We had a hard time keeping up with the frequent releases and
the new functionality that kept on coming. But, it also was a lot of fun to be able to
write about a new functionality that was just (or about to be) released.
www.it-ebooks.info
PREFACE
xx
After a few meet-ups with the Activiti developer community and a couple of nice
dinners with the Activiti team, we began discussing the possibility of my joining
Alfresco to work on Activiti. In May 2011, I accepted the offer and was able to begin
working on Activiti full-time.
In the meantime, the writing of this book fell a little behind schedule. There was
so much interesting work to be done developing the Activiti Designer, working on
the Activiti Engine, and starting in a new job, that time caught up with me. After I
had settled in a bit, I took up the writing task again and began working on the
remaining chapters.
So here I am, at the end of the process. I’ve switched from being a consultant to an

ACKNOWLEDGMENTS
xxii
Sven Vintges, Joram Barrez, Jeff Davis, Gordon Dickens, Roy Prins, Claus Ibsen, Feder-
ico Tomassetti, Greg Helton, Mykel Alvis, and Nicolas Leroux.
Finally, my appreciation to everyone at Manning, starting with publisher Marjan
Bace, my editor Sebastian Stirling, and the production team of June Eding, Nermina
Miller, Mary Piergies, Gordan Salinovic, and Janet Vail.
www.it-ebooks.info
xxiii
about this book
Activiti is an open source Business Processing Model and Notation (BPMN) 2.0 process
engine framework that provides an environment for running your business and tech-
nical processes. It’s a project funded by Alfresco and established by j
BPM founder Tom
Baeyens. Activiti provides much more functionality than simply running BPMN 2.0 pro-
cesses in a rock-solid way. It provides a web-based modeling tool for business analysts, an
Eclipse plug-in for developers, and a web application to work with and manage the pro-
cesses. In addition, Activiti community members, including SpringSource, FuseSource,
MuleSoft, and camunda, have implemented further functionality like full Spring inte-
gration, an OSGi bundle, Mule and Camel integration, and a
CDI module.
This book is written by one of the Activiti core developers and the lead developer
of the Activiti Designer component. It contains loads of examples to help you under-
stand the
BPMN 2.0 language and how to work with all the extensions Activiti provides.
In the final chapters, the book goes beyond Activiti’s core functionality and shows how
to do
CMIS communication from a process definition and how to implement a busi-
ness activity monitoring environment using the open source Esper framework.
You should not expect to find examples of all the nitty-gritty details of the


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status