devoxx 2009 university session jbpm4 in action
TRANSCRIPT
![Page 1: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/1.jpg)
jBPM 4 in ActionjBPM 4 in Actionby by
Tom Baeyens & Joram BarrezTom Baeyens & Joram Barrez
![Page 2: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/2.jpg)
2
Speaker’s qualificationsFounded jBPM in 2003Project Lead of jBPMPassionate about BPM and JavaArticles/international conferences
JBoss jBPM core developer (06/09)Before: jBPM/BPM consultant
![Page 3: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/3.jpg)
3
Agenda
Part 1Part 2Part 3
Part 4
Very interesting
REALLY interesting !
![Page 4: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/4.jpg)
4
jBPM is great for BPM*and*
for developers
![Page 5: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/5.jpg)
makes your work flow
![Page 6: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/6.jpg)
![Page 7: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/7.jpg)
![Page 8: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/8.jpg)
8
Business process
An (organized) way of 'doing things'
... with a certain goal
![Page 9: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/9.jpg)
9
History lesson1723-1790, Adam Smith: The pin factory
– Labor division
1863-1947, Henry Ford: mass production– Assembly lines– Specialization
![Page 10: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/10.jpg)
10
History lessonWilliam E. Deming (1900-1993)
'Hero' of Japanese industryManufacturing processes ++
– Quality Circle– SPC– Six-Sigma– ...
![Page 11: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/11.jpg)
11
Processes are everywhere
![Page 12: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/12.jpg)
Processes are everywhere
![Page 13: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/13.jpg)
![Page 14: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/14.jpg)
14
Conclusion
Any company Any productAny service
They all have business processes
![Page 15: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/15.jpg)
15
Conclusion
Any company Any productAny service
Which means– 'Doing business'
== executing some business process
They all have business processes
![Page 16: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/16.jpg)
![Page 17: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/17.jpg)
![Page 18: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/18.jpg)
18
The M in BPM
Business processes are ubiquitous
But ... this doesn't mean that– People know they are part of one– Everybody is doing the same – They are controlled or guided
![Page 19: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/19.jpg)
19
The M in BPM
Managing business processes means– Everybody knows the what/when– There is guidance or control– Measurement (KPI)
Not a matter of 'buying BPM'– Organisational changes– Discipline
![Page 20: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/20.jpg)
20
BPM Systems
~BPM engine or workflow engineExecutes the business processes
– Diagram––––– <tech-details />
![Page 21: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/21.jpg)
21
Introducing jBPM
Transactional state-machineGeneric graph execution engine
![Page 22: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/22.jpg)
22
Introducing jBPM
Transactional state-machineGeneric graph execution engine
But most of all...– A kick-ass BPM engine
![Page 23: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/23.jpg)
23
Main business advantages
Diagram: no disconnection between– What business expects– What IT delivers
AgileVisibility
– Monitoring, CEP, KPI
![Page 24: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/24.jpg)
24
Main technical advantagesSolves scattered business logic problem
– Clean separation between data/logicAudit/task mgmt/... capabilities for freeDoesn't dictate your architecture
– Embed with any java framework– Any transaction configuration– Any environment
![Page 25: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/25.jpg)
25
jBPM history
4 Jan 2003 : 5, 4, 3, 2, 1
... rrrrrrooooaaaaarrrrr ... and we have a lift off !
jBpm is present in sourceforge.net
![Page 26: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/26.jpg)
26
jBPM history
4 Jan 2003 : 5, 4, 3, 2, 1
... rrrrrrooooaaaaarrrrr ... and we have a lift off !
jBpm is present in sourceforge.net
![Page 27: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/27.jpg)
27
jBPM history
18 Oct 2004 : released JBoss jBPM 2.0
![Page 28: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/28.jpg)
28
jBPM history
![Page 29: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/29.jpg)
29
jBPM history
24 May 2005 : The team is proud to declare
the beta1 releases of JBoss jBPM 3.0 !
Check out the sourceforge download pages and have fun...
8 may 2006: We are happy to announce
the release of JBoss jBPM 3.1.1.
![Page 30: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/30.jpg)
30
jBPM history
They grow so fast...
3.1.2 3.1.3 3.1.43.2.0 3.2.1 3.2.2 3.2.3
3.2.4 3.2.5 3.2.6
'Back in the days I had spent a full two hours with MS Paint to create the first logo for jBPM.'
'Now that my project even had a logo, I was in full confidence. Nothing could stop me now'
![Page 31: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/31.jpg)
31
jBPM history
They grow so fast...
3.1.2 3.1.3 3.1.43.2.0 3.2.1 3.2.2 3.2.3
3.2.4 3.2.5 3.2.6
'Back in the days I had spent a full two hours with MS Paint to create the first logo for jBPM.'
'Now that my project even had a logo, I was in full confidence. Nothing could stop me now'
'So I went to the conference and immediately I got a lot of valuable feedback'
.'Hey Tom, you're project is great
but your logo sucks bigtime!'
![Page 32: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/32.jpg)
32
jBPM history
They grow so fast...
3.1.2 3.1.3 3.1.43.2.0 3.2.1 3.2.2 3.2.3
3.2.4 3.2.5 3.2.6
'This time I sticked to coding and left the paint job to the professionals. '
![Page 33: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/33.jpg)
33
jBPM history
July 2009:
jBPM4 is out!
![Page 34: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/34.jpg)
34
jBPM history
November 2009
jBPM 4.2 released
![Page 35: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/35.jpg)
Today
![Page 36: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/36.jpg)
Today
![Page 37: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/37.jpg)
37
JBPM v4: what's new?Core engine completely revised
– 2nd generation PVM– Designed for cluster & performance– Not losing what made jBPM3 great
Incorporated lessons learned – 6 years of usage in the wild– Corner cases and even edgier– Simplified 'getting started'
![Page 38: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/38.jpg)
38
JBPM v4: what's new?Clean & simplified
– New API (incl. cool query mechanism)– Compact db schema– Native Spring integration
Performance boostImproved tooling
– Sexy GWT console – Signavio web modeling
QA lab
![Page 39: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/39.jpg)
jBPM3 jBPM4
![Page 40: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/40.jpg)
40
JBPM v4: performanceDesigned with performance in mind
– Scalability/clusterability– Improved inner workings
Test method– 5 processes– Start --> end– 10K executions, 1-10 fixed threadpool
![Page 41: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/41.jpg)
41
JBPM v4: performance
process01 process02 process03 process04 process05 random0
2
4
6
8
10
12
14
jBPM 4.2 basic benchmark - MySQL 5(10 000 execut ions)
Seq. exec.2 fixedTP3 fixedTP4 fixedTP5 fixedTP6 fixedTP7 fixedTP8 fixedTP9 fixedTP10 fixedTPav
g du
ratio
n (m
s)
Config: Ubuntu 9.04, AMD Phenom II X4 3.0Ghz, 8Gb Ram, 7200rpm HDDB and benchmark on same machine
![Page 42: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/42.jpg)
42
JBPM v4: performance
process01 process02 process03 process04 process05 random0
2
4
6
8
10
12
jBPM 4.2 basic benchmark - Postgresql 8.3(10 000 executions)
Seq. exec.2 fixedTP3 fixedTP4 fixedTP5 fixedTP6 fixedTP7 fixedTP8 fixedTP9 fixedTP10 fixedTPav
g du
ratio
n (m
s)
Config: Ubuntu 9.04, AMD Phenom II X4 3.0Ghz, 8Gb Ram, 7200rpm HDDB and benchmark on same machine
![Page 43: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/43.jpg)
43
JBPM v4: performance
process01 process02 process03 process04 process05 random0
2
4
6
8
10
12
jBPM 4.2 basic benchmark - Postgresql 8.3(10 000 executions)
Seq. exec.2 fixedTP3 fixedTP4 fixedTP5 fixedTP6 fixedTP7 fixedTP8 fixedTP9 fixedTP10 fixedTPav
g du
ratio
n (m
s)
Config: Ubuntu 9.04, AMD Phenom II X4 3.0Ghz, 8Gb Ram, 7200rpm HDDB and benchmark on same machine
![Page 44: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/44.jpg)
44
JBPM v4: performance
Avg process exec. time– 0.75ms – 2ms– 1.8 mil./hour– Yeah, that's fast
jBPM overhead == (extremely) minimal– So what are you waiting for?
![Page 45: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/45.jpg)
Part 2: jBPM ConceptsPart 2: jBPM Concepts
![Page 46: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/46.jpg)
A Process
![Page 47: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/47.jpg)
An Execution
Execution
![Page 48: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/48.jpg)
History
HISTORY_PROCESS_INSTANCE
ID START END …PROCESS
HISTORY_ACTIVITY_INSTANCE
ID START END …HPI ACTIVITY
2 09:391 Check Credit09:39
3 09:421 Accept Quote09:42
4 10:031 Charge Customer10:0310:04
10:041 09:38Order-1
1 09:381 Calculate Quote
![Page 49: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/49.jpg)
History
![Page 50: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/50.jpg)
Software ProjectExecutable Business Process
Processes As Part Of Software Development
Abstract Business Process
Non-techBusiness Analyst Developer<details />
Java, XML, Buildscripts,Tests, …
EAPSOA-PJBossTomcatJDK 5
Oracle, MySQL, PostgreSQL
jBPM YourApp
![Page 51: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/51.jpg)
SignavioWeb
Modeling
BPM Console
Task UI
JoprBAM BISimu
lation
Model Repository
MavenRepository
SVN Repository
jBPM
PVM
Repository
Executions
History
Tasks
jPDL BPMN2
RepoService
ExeService
HistService
TaskService
Identities
•Users•Groups•Memberships
…
![Page 52: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/52.jpg)
![Page 53: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/53.jpg)
jPDL
• BPM focussed• Graph based• Readable, editable XML• Direct Java integration• Extended task management• Community
Available now!
![Page 54: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/54.jpg)
BPMN 2.0• BPM focussed• Graph based• Upcoming standard• Focus on modeling notation
Coming Soon!
![Page 55: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/55.jpg)
Building Community
BPEL 2.0• Web Service focussed (WSDL)• Script new service
as a function of other services• Block structured
![Page 56: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/56.jpg)
jBPM Overview
Repository
JVM
jBPM.jar
JDBC
RepositoryServiceExecutions
History
Tasks
Identity
ExecutionServiceHistoryServiceTaskService
IdentityService
YourApplication
![Page 57: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/57.jpg)
jBPM APIConfiguration cfg = new Configuration();
ProcessEngine processEngine = cfg.buildProcessEngine();
processEngine.getRepositoryService();processEngine.getExecutionService();processEngine.getHistoryService();processEngine.getTaskService();processEngine.getIdentityService();
jbpm.cfg.xml
![Page 58: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/58.jpg)
jbpm.cfg.xml<jbpm-configuration> <import resource="jbpm.default.cfg.xml" /> <import resource="jbpm.tx.hibernate.cfg.xml" /> <import resource="jbpm.jpdl.cfg.xml" /> <import resource="jbpm.identity.cfg.xml" /> <import resource="jbpm.businesscalendar.cfg.xml" /> <import resource="jbpm.console.cfg.xml" /> <import resource="jbpm.jobexecutor.cfg.xml" /></jbpm-configuration>
![Page 59: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/59.jpg)
Installer Ant Scripts• Install, start & stop
– Hsqldb– JBoss– Tomcat
• Create, upgrade & drop jBPM schema
• Install jBPM into– JBoss (service archive)– Tomcat (libs+config)
![Page 60: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/60.jpg)
Part 3: Demo ExamplesPart 3: Demo Examples
![Page 61: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/61.jpg)
61
Getting started demo
Working with processes– Can be overwhelming (at first)
Downloaded zip -> business process– Let's hope the demo gods aren't looking
Basically ... a free training!– Please don't tell our bosses
![Page 62: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/62.jpg)
62
Demo process
Ordering conference goodies
![Page 63: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/63.jpg)
63
First steps
Set up dev environmentUsing jBPM in embedded modeWork in iterations
– Create basic process (start–task-end)
– TDD our process
![Page 64: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/64.jpg)
64
jBPM 4 Task
Process execution waitsProcess state is persistedNew task created in DBFunctionality
– 'Work list': assignee, candidate-groups/users, swimlane, handler, ...
– notification/reminder mail– Timers
![Page 65: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/65.jpg)
65
DEMODEMO•First stepsFirst steps
![Page 66: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/66.jpg)
66
jBPM 4 DIY: custom activity
Business processes are business specificWe have a set of common activities
– And even more planned (jms, ejb, rules, calling your grandmother, ...)
Custom activities will always be neededPojo:<custom name="payout" class="com.devoxx.jbpm4.PayoutActivity"> <transition to="end1" /></custom>
![Page 67: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/67.jpg)
67
DEMODEMO•DIY: custom activitiesDIY: custom activities
![Page 68: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/68.jpg)
68
Decision
Automatic choice of process flow– Process data– Business rule
Actual decision– Expression– Custom DecisionHandler
![Page 69: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/69.jpg)
69
Decision - handler<decision name="evaluate document"> <handler class="org.jbpm.xx.ContentEvaluation" /> <transition name="good" to="submit document" /> <transition name="bad" to="try again" /> <transition name="ugly" to="give up" /></decision>
public class ContentEvaluation implements DecisionHandler { public String decide(OpenExecution execution) { ... }}
![Page 70: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/70.jpg)
70
Decision - expression
Expression language– Juel (2.2: +methods)– Groovy– ...
<decision name="evaluate document" expr="#{content}" > <transition name="good" to="submit document" /> <transition name="bad" to="try again" /> <transition name="ugly" to="give up" /></decision>
![Page 71: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/71.jpg)
71
Decision - expression
Expression language– Juel (2.2: +methods)– Groovy– ...
<decision name="checkPayment" > <transition name="expensive" to="pay less" > <condition expr=”#{order.amount > 999}” /> </transition> <transition name="cheap" to="pay more" /> <condition expr=”#{order.amount < 1000}” /> </transition></decision>
Process variable
![Page 72: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/72.jpg)
72
DEMODEMO• DecisionsDecisions
![Page 73: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/73.jpg)
73
Put it in 'staging'
Next steps– Switch to a real database– jBPM web console– Deploy process as part of build (dev)– Incorporate task forms for user IO
simulation
![Page 74: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/74.jpg)
74
Task form
Part of deployment – deployment.addResourceFromClasspath(…./my_form.ftl);– <task form="com/devoxx/jbpm4/my_form.ftl"
Freemarker templates– ${processVar}– <input type=”text” name=”myVar” />– Css
![Page 75: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/75.jpg)
75
DEMODEMO• Switching to the real stuffSwitching to the real stuff
![Page 76: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/76.jpg)
Part 4: Advanced ConceptsPart 4: Advanced Concepts
![Page 77: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/77.jpg)
Agenda• jBPM Architecture• Process Deployment• Execution and persistence• Transactional control flow• More core features
![Page 78: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/78.jpg)
graph execution+
pers is tence=
transactional control flow
![Page 79: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/79.jpg)
jBPM Architecture: POJO Core• POJO Classes representing
– Process definitions– Runtime executions– History, tasks, identities,...
• Behaviour in the domain model• Domain model persistable with hibernate
![Page 80: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/80.jpg)
ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess() .startActivity("creditRate?", new
AutomaticCreditRating()) .initial() .transition("priority delivery", "good") .transition("payment upfront", "bad") .endActivity() .startActivity("priority delivery", new WaitState()) .endActivity() .startActivity("payment upfront", new WaitState()) .endActivity() .endProcess();
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.setVariable("creditRate", 7);processInstance.start();
incubation
![Page 81: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/81.jpg)
jBPM Architecture: Services• Infrastructure around domain model
– Embeddability– Persistence / transactions
• Services• Interceptors• Environment• Commands
![Page 82: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/82.jpg)
Services• Main API• Services expose methods• Each method 1 command• Commands passed down interceptor stack
– Aka chain of command– Configurable interceptor stack
![Page 83: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/83.jpg)
Servicespublic class ExecutionServiceImpl {
... public ProcessInstance startProcessInstanceById(String procDefId) {
return commandService.execute( new StartProcessInstanceCmd(procDefId,null,null)
); } ...
![Page 84: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/84.jpg)
Configurable Interceptor Stacks• Standalone• JTA• Spring• Remote• Async
incubation
![Page 85: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/85.jpg)
Environment• Decouples POJO model from environment• Interceptorstack responsible
for setting up the environment• Domain model looks up configurable
stuff from the environment• E.g. hibernate session
![Page 86: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/86.jpg)
Commands• Invoke methods on POJO's• Persistence operations
– Load– Save
![Page 87: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/87.jpg)
![Page 88: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/88.jpg)
Persistence
no
submit web sale
sales review
fork
end
send bill
wait for payment
join
ship items
all shipped ?
yes
![Page 89: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/89.jpg)
Persistence
no
submit web sale
sales review
fork
end
send bill
wait for payment
join
ship items
all shipped ?
yes
Execution
Transaction
1. Load
![Page 90: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/90.jpg)
Persistence
no
submit web sale
sales review
fork
end
send bill
wait for payment
join
ship items
all shipped ?
yes
2. UpdateExecution
Transaction
![Page 91: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/91.jpg)
Persistence
no
submit web sale
sales review
fork
end
send bill
wait for payment
join
ship items
all shipped ?
yes
3. Save changes
Execution
Transaction
![Page 92: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/92.jpg)
How Does jBPM Do It?• Deployment• Automatic activities• Wait states• Process concurrency• Async Continuations• Timers
![Page 93: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/93.jpg)
A Business Archive• Plain jar formatted file• .bar extension• Contents
– Process files– Process image– Classes– Forms– Rules– …
![Page 94: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/94.jpg)
Deployment
![Page 95: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/95.jpg)
Deployment With APIRepositoryService repositoryService =
processEngine.getRepositoryService();
String deploymentId =repositoryService.createDeployment() .addResourcesFromZipInputStream( “order.bar”) .deploy();
![Page 96: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/96.jpg)
Deployment With Ant<jar destfile="order.bar"> ...</jar>
<taskdef name="jbpm-deploy" classname="org.jbpm.pvm.internal.ant.JbpmDeployTask" classpathref="jbpm.libs.and.cfg" />
<jbpm-deploy file="order.bar" />
![Page 97: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/97.jpg)
Deployment• Deployment
– HashMap– Representing zip file– Named resources
• Key– Entry name– String
• Value– Blob– byte[]
order.jpdl.xml 11111011…order.jpg 01011100…com/pinokkio/Order.class 00100100…order.rules.drl 01110100…
DEPLOYMENT “1”
Process class
versioning !
![Page 98: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/98.jpg)
Deployers• Scan deployments• Publish objects• RepositoryCache
RepositoryCache
OrderRuleBase
DeployerJpdlDeployerorder.jpdl.xml 11111011…order.jpg 01011100…com/pinokkio/Order.class 00100100…OrderStartForm.ftl 01110100…
DEPLOYMENT “1”
DEPLOYMENT 1
DeploymentClassLoader
![Page 99: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/99.jpg)
Process Instance• All state related to 1 execution of a
process definition• Potentially multiple pointers
keeping track of concurrent paths of execution
• Variables• Timers
![Page 100: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/100.jpg)
Execution• 1 path of execution
– 1 set of variables– 1 set of timers
![Page 101: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/101.jpg)
Structure• 1 process instance is a tree of executions
– Concurrency– Variable
scoping– Competing
events in 1 scope
![Page 102: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/102.jpg)
Full Automatic Example
![Page 103: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/103.jpg)
<process name="Automatic">
<start> <transition to="print dots" /> </start>
<custom name="print dots" class="com.devoxx.jbpm.automatic.PrintDots"> <transition to="end" /> </custom> <end name="end"/>
</process>
![Page 104: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/104.jpg)
Starting ProcessInstance
public void userClickedButtonEjbSessionCmt() { ... ProcessInstance processInstance = executionService
.startProcessInstanceByKey("example") ...}
SomeWeb
Framework
Tomcat
![Page 105: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/105.jpg)
Inside startProcessInstanceByKey• New execution• Executes “print dots”• Execution ends (deleted)• History remains
– Net result– Part of user TX
![Page 106: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/106.jpg)
Demo: Automatic ActivityDemo: Automatic Activity
![Page 107: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/107.jpg)
Observation• Automatic activities
run in thread of the web app• Exceptions in process
roll back webapp transaction• Error message to the user
![Page 108: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/108.jpg)
Waiting• Thread nor transaction should be
blocked for long periods– Not scalable
• Waiting for – A user completing a task– An message from an external system– Some other web request– Anything for which
you don’t want to block the thread/transaction
![Page 109: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/109.jpg)
Persisting State• Current state
– Position in process graph– Variables– Timers
• Waiting means – Persisting state– Committing transaction
![Page 110: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/110.jpg)
A Basic Wait State
![Page 111: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/111.jpg)
<process name="WaitState">
<start> <transition to="print dots" /> </start>
<custom name="print dots" class="com.devoxx.jbpm.automatic.PrintDots"> <transition to="wait" /> </custom>
<state name="wait"> <transition to="end" /> </state>
<end name="end" />
</process>
![Page 112: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/112.jpg)
A Wait State• Execution will wait• Until a signal is given• Typically
– EventListener on start of state activity
– External trigger continues process• MDB, DB trigger, file scanner,...
![Page 113: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/113.jpg)
Wait State Persistence1. executionService
.s tartProcess InstanceByKey(...)1. Creates new execution2. Starts executing from start activity3. Execution arrives in s tate4. Execution state will be saved5. Transaction will be committed6. jBPM service method will return
![Page 114: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/114.jpg)
Wait State Persistence2. Time goes by
– Execution state remains in the DB
![Page 115: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/115.jpg)
Wait State Persistence3. executionService
.s ignalExecutionById(...)1. Loads the execution2. Takes an outgoing transition3. Continues execution till next wait state4. Stores execution updates5. Commit transaction6. signalExecutionById returns
![Page 116: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/116.jpg)
A Basic Wait State
// e.g. in the button click codeProcessInstance processInstance = executionService .startProcessInstanceByKey("WaitState");assertFalse(processInstance.isEnded());String pid = processInstance.getId();
// much later. e.g in another request or MDB executionService.signalExecutionById(pid);
transaction
transaction
![Page 117: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/117.jpg)
Testing• Process == software• Test == 1 scenario• Provide external triggers• Assert execution state• Support for
– Integration testing• Test process as is
– Unit testing• Process updates allow stubs
![Page 118: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/118.jpg)
Demo: Wait S tate ActivityDemo: Wait S tate Activity
![Page 119: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/119.jpg)
Process Execution Timeline
![Page 120: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/120.jpg)
Transactional Control Flow
Auto State AutoAuto Auto State Auto
1. executionService.startProcessInstanceByKey(…)
Java Object:
SQL: INSERT INTO JBPM4_EXECUTION …
execution
![Page 121: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/121.jpg)
Transactional Control Flow
Auto State AutoAuto Auto State Auto
2. executionService.signalExecutionById(…)
Java Object:
SQL: UPDATE JBPM4_EXECUTION …
execution
![Page 122: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/122.jpg)
Transactional Control Flow
Auto State AutoAuto Auto State Auto
3. executionService.signalExecutionById(…)
Java Object:
SQL: DELETE JBPM4_EXECUTION …
execution
![Page 123: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/123.jpg)
Concurrency• Parallel execution of activities• E.g. Order
– Shipping – Billing
• E.g. Loan– Sending loan money– Archiving contracts
![Page 124: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/124.jpg)
Execution Concurrency
![Page 125: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/125.jpg)
EventListeners• Attach POJO java code
to process execution event• Hidden from the graph
– For technical aspects
![Page 126: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/126.jpg)
<process name="WaitState">
<start> <transition to="wait" /> </start>
<state name="wait"> <on event="start"> <event-listener event="com.devoxx.jbpm.DoHidden"> </on> <transition to="end" /> </state>
<end name="end" />
</process>
![Page 127: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/127.jpg)
public class DoHidden implements EventListener {
public void notify(EventListenerExecution execution) {
... }}
![Page 128: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/128.jpg)
Asynchronous Continuations• Automatic activities in sequence• One takes a long time
– E.g. pdf generation• Don’t block the client thread• async=“true”
pdf-g
Transaction 1 Transaction 2
JobExecutor
![Page 129: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/129.jpg)
Timers• Actions
– Take Transition– Event listeners
• Also handled by JobExecutor• Business Calendar
– 15 minutes– 4 bus iness hours
![Page 130: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/130.jpg)
Variables• HashMap associated to execution• Configurable type system• Scoping
![Page 131: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/131.jpg)
Other Important Features• SEAM integration• Spring integration• Instance migration• Automatic upgrades
![Page 132: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/132.jpg)
Summary
• Fits ins ide your architecture• S upports multiple process languages• Facilitates collaboration• jBPM has real value for real developers
– Model process– Play with transactions– Write POJO code
![Page 133: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/133.jpg)
I just know you're excited to give it a try
You can do it tonight Just before you go to sleep Or even in your bed
Last demo movie
Getting started
![Page 134: Devoxx 2009 University session Jbpm4 In Action](https://reader033.vdocument.in/reader033/viewer/2022051515/554f7b8cb4c9052a518b4a8b/html5/thumbnails/134.jpg)
http://jbpm.orghttp://processdevelopments.blogspot.comhttp://jorambarrez.be/blog
makes your work flowQ&AQ&A