• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Devoxx 2009 University session Jbpm4 In Action
 

Devoxx 2009 University session Jbpm4 In Action

on

  • 4,250 views

 

Statistics

Views

Total Views
4,250
Views on SlideShare
3,792
Embed Views
458

Actions

Likes
2
Downloads
192
Comments
0

3 Embeds 458

http://www.jorambarrez.be 438
http://www.slideshare.net 19
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Devoxx 2009 University session Jbpm4 In Action Devoxx 2009 University session Jbpm4 In Action Presentation Transcript

    • jBPM 4 in Action by Tom Baeyens & Joram Barrez
    • Speaker’s qualifications Founded jBPM in 2003 Project Lead of jBPM Passionate about BPM and Java Articles/international conferences JBoss jBPM core developer (06/09) Before: jBPM/BPM consultant 2
    • Agenda Part 1 Part 2 Very interesting Part 3 Part 4 REALLY interesting ! 3
    • jBPM is great for BPM *and* for developers 4
    • makes your work flow
    • Business process An (organized) way of 'doing things' ... with a certain goal 8
    • History lesson 1723-1790, Adam Smith: The pin factory – Labor division 1863-1947, Henry Ford: mass production – Assembly lines – Specialization 9
    • History lesson William E. Deming (1900-1993) 'Hero' of Japanese industry Manufacturing processes ++ – Quality Circle – SPC – Six-Sigma – ... 10
    • Processes are everywhere 11
    • Processes are everywhere
    • Conclusion Any company They all have Any product business processes Any service 14
    • Conclusion Any company They all have Any product business processes Any service Which means – 'Doing business' == executing some business process 15
    • 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 18
    • 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 19
    • BPM Systems ~BPM engine or workflow engine Executes the business processes – Diagram – – – – – <tech-details /> 20
    • Introducing jBPM Transactional state-machine Generic graph execution engine 21
    • Introducing jBPM Transactional state-machine Generic graph execution engine But most of all... – A kick-ass BPM engine 22
    • Main business advantages Diagram: no disconnection between – What business expects – What IT delivers Agile Visibility – Monitoring, CEP, KPI 23
    • Main technical advantages Solves scattered business logic problem – Clean separation between data/logic Audit/task mgmt/... capabilities for free Doesn't dictate your architecture – Embed with any java framework – Any transaction configuration – Any environment 24
    • jBPM history 4 Jan 2003 : 5, 4, 3, 2, 1 ... rrrrrrooooaaaaarrrrr ... and we have a lift off ! jBpm is present in sourceforge.net 25
    • jBPM history 4 Jan 2003 : 5, 4, 3, 2, 1 ... rrrrrrooooaaaaarrrrr ... and we have a lift off ! jBpm is present in sourceforge.net 26
    • jBPM history 18 Oct 2004 : released JBoss jBPM 2.0 27
    • jBPM history 28
    • 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. 29
    • jBPM history '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' They grow so fast... 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 30
    • jBPM history '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!' They grow so fast... 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 31
    • jBPM history 'This time I sticked to coding and left the paint job to the professionals. ' They grow so fast... 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 32
    • jBPM history July 2009: jBPM4 is out! 33
    • jBPM history November 2009 jBPM 4.2 released 34
    • Today
    • Today
    • 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' 37
    • JBPM v4: what's new? Clean & simplified – New API (incl. cool query mechanism) – Compact db schema – Native Spring integration Performance boost Improved tooling – Sexy GWT console – Signavio web modeling QA lab 38
    • jBPM3 jBPM4
    • JBPM v4: performance Designed with performance in mind – Scalability/clusterability – Improved inner workings Test method – 5 processes – Start --> end – 10K executions, 1-10 fixed threadpool 40
    • JBPM v4: performance jBPM 4.2 basic benchmark - MySQL 5 (10 000 executio ns) 14 12 Seq. exec. 10 2 fixedTP 3 fixedTP 4 fixedTP avg duration (ms) 8 5 fixedTP 6 fixedTP 7 fixedTP 6 8 fixedTP 9 fixedTP 10 fixedTP 4 2 0 proces s01 proces s 02 proces s 03 proces s 04 proces s 05 random Config: Ubuntu 9.04, AMD Phenom II X4 3.0Ghz, 8Gb Ram, 7200rpm HD DB and benchmark on same machine 41
    • JBPM v4: performance jBPM 4.2 basic benchmark - Postgresql 8.3 (10 000 executio ns) 12 10 Seq. exec. 2 fixedT P 8 3 fixedT P 4 fixedT P avg duration (ms) 5 fixedT P 6 fixedT P 6 7 fixedT P 8 fixedT P 9 fixedT P 4 10 fixedTP 2 0 process 01 proces s 02 proces s 03 proces s 04 proces s 05 random Config: Ubuntu 9.04, AMD Phenom II X4 3.0Ghz, 8Gb Ram, 7200rpm HD DB and benchmark on same machine 42
    • JBPM v4: performance jBPM 4.2 basic benchmark - Postgresql 8.3 (10 000 executio ns) 12 10 Seq. exec. 2 fixedT P 8 3 fixedT P 4 fixedT P avg duration (ms) 5 fixedT P 6 fixedT P 6 7 fixedT P 8 fixedT P 9 fixedT P 4 10 fixedTP 2 0 process 01 proces s 02 proces s 03 proces s 04 proces s 05 random Config: Ubuntu 9.04, AMD Phenom II X4 3.0Ghz, 8Gb Ram, 7200rpm HD DB and benchmark on same machine 43
    • 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? 44
    • Part 2: jB PM C oncepts
    • A Process
    • An Execution Execution
    • History HISTORY_PROCESS_INSTANCE ID PROCESS START END … 1 Order-1 09:38 10:04 HISTORY_ACTIVITY_INSTANCE ID HPI ACTIVITY START END … 1 1 Calculate Quote 09:38 09:39 2 1 Check Credit 09:39 09:42 3 1 Accept Quote 09:42 10:03 4 1 Charge Customer 10:03 10:04
    • History
    • Processes As Part Of Software Development Software Project Abstract Business Process Executable Business Process Non-tech Business Analyst <details /> Developer Java, XML, Buildscripts, Tests, … EAP jBPM Your SOA-P App JBoss Tomcat JDK 5 Oracle, MySQL, PostgreSQL
    • Signavio Simu BPM BAM BI Web lation Console Jopr Modeling Task Model UI Repository jBPM jPDL BPMN2 … SVN PVM Repository Maven Repository RepoService Repository Executions ExeService History HistService Tasks TaskService Identities •Users •Groups •Memberships
    • jPDL Av ail ab le no w! • BPM focussed • Graph based • Readable, editable XML • Direct Java integration • Extended task management • Community
    • B PMN 2.0 Co mi ng So on ! • BPM focussed • Graph based • Upcoming standard • Focus on modeling notation
    • B PEL 2.0 B Co uild mm ing un ity • Web Service focussed (WSDL) • Script new service as a function of other services • Block structured
    • jBPM Overview JDBC Repository jBPM.jar Your Executions RepositoryService Application History ExecutionService Tasks Identity HistoryService TaskService IdentityService JVM
    • jBPM API jbpm.cfg.xml Configuration cfg = new Configuration(); ProcessEngine processEngine = cfg.buildProcessEngine(); processEngine.getRepositoryService(); processEngine.getExecutionService(); processEngine.getHistoryService(); processEngine.getTaskService(); processEngine.getIdentityService();
    • 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>
    • Installer Ant Scripts • Install, start & stop – Hsqldb – JBoss – Tomcat • Create, upgrade & drop jBPM schema • Install jBPM into – JBoss (service archive) – Tomcat (libs+config)
    • Part 3: Demo Examples
    • 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 61
    • Demo process Ordering conference goodies 62
    • First steps Set up dev environment Using jBPM in embedded mode Work in iterations – Create basic process (start–task-end) – TDD our process 63
    • jBPM 4 Task Process execution waits Process state is persisted New task created in DB Functionality – 'Work list': assignee, candidate- groups/users, swimlane, handler, ... – notification/reminder mail – Timers 64
    • DEMO •First steps 65
    • jBPM 4 DIY: custom activity Business processes are business specific We have a set of common activities – And even more planned (jms, ejb, rules, calling your grandmother, ...) Custom activities will always be needed Pojo: <custom name="payout" class="com.devoxx.jbpm4.PayoutActivity"> <transition to="end1" /> </custom> 66
    • DEMO •DIY: custom activities 67
    • Decision Automatic choice of process flow – Process data – Business rule Actual decision – Expression – Custom DecisionHandler 68
    • 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) { ... } } 69
    • 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> 70
    • Decision - expression Expression language – Juel (2.2: +methods) – Groovy – ... Process variable <decision name="checkPayment" > <transition name="expensive" to="pay less" > <condition expr=”#{order.amount &gt; 999}” /> </transition> <transition name="cheap" to="pay more" /> <condition expr=”#{order.amount &lt; 1000}” /> </transition> </decision> 71
    • DEMO • Decisions 72
    • 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 73
    • 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 74
    • DEMO • Switching to the real stuff 75
    • Part 4: Advanced C oncepts
    • Agenda • jBPM Architecture • Process Deployment • Execution and persistence • Transactional control flow • More core features
    • g raph execution + pers is tence = trans actional control flow
    • jBPM Architecture: POJO Core • POJO Classes representing – Process definitions – Runtime executions – History, tasks, identities,... • Behaviour in the domain model • Domain model persistable with hibernate
    • ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess() inc ub .startActivity("creditRate?", new ati on 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();
    • jBPM Architecture: Services • Infrastructure around domain model – Embeddability – Persistence / transactions • Services • Interceptors • Environment • Commands
    • Services • Main API • Services expose methods • Each method 1 command • Commands passed down interceptor stack – Aka chain of command – Configurable interceptor stack
    • Services public class ExecutionServiceImpl { ... public ProcessInstance startProcessInstanceById(String procDefId) { return commandService.execute( new StartProcessInstanceCmd(procDefId,null,null) ); } ...
    • Configurable Interceptor Stacks • Standalone • JTA • Spring inc • Remote ub ati on • Async
    • 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
    • Commands • Invoke methods on POJO's • Persistence operations – Load – Save
    • Persistence submit web sale sales review fork send bill ship items wait for payment all shipped ? no yes join end
    • Persistence submit web sale Transaction sales review fork Execution send bill ship items wait for payment no 1. Load all shipped ? yes join end
    • Persistence submit web sale Transaction sales review 2. Update fork Execution send bill ship items wait for payment all shipped ? no yes join end
    • Persistence submit web sale Transaction sales review fork Execution send bill ship items wait for payment no 3. Save changes all shipped ? yes join end
    • How Does jBPM Do It? • Deployment • Automatic activities • Wait states • Process concurrency • Async Continuations • Timers
    • A Business Archive • Plain jar formatted file • .bar extension • Contents – Process files – Process image – Classes – Forms – Rules –…
    • Deployment
    • Deployment With API RepositoryService repositoryService = processEngine.getRepositoryService(); String deploymentId = repositoryService.createDeployment() .addResourcesFromZipInputStream( “order.bar”) .deploy();
    • 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" />
    • Deployment Pr • Deployment oc ve ess rsi – HashMap on clas ing s ! – Representing zip file – Named resources • Key – Entry name – String DEPLOYMENT “1” order.jpdl.xml 11111011… • Value order.jpg 01011100… – Blob com/pinokkio/Order.class 00100100… order.rules.drl 01110100… – byte[]
    • Deployers RepositoryCache • Scan deployments DEPLOYMENT 1 • Publish objects Order RuleBase • RepositoryCache Deployment ClassLoader DEPLOYMENT “1” order.jpdl.xml 11111011… Deployer order.jpg 01011100… JpdlDeployer com/pinokkio/Order.class 00100100… OrderStartForm.ftl 01110100…
    • Process Instance • All state related to 1 execution of a process definition • Potentially multiple pointers keeping track of concurrent paths of execution • Variables • Timers
    • Execution • 1 path of execution – 1 set of variables – 1 set of timers
    • Structure • 1 process instance is a tree of executions – Concurrency – Variable scoping – Competing events in 1 scope
    • Full Automatic Example
    • <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>
    • Starting ProcessInstance Tomcat Some Web Framework public void userClickedButtonEjbSessionCmt() { ... ProcessInstance processInstance = executionService .startProcessInstanceByKey("example") ... }
    • Inside startProcessInstanceByKey • New execution • Executes “print dots” • Execution ends (deleted) • History remains – Net result – Part of user TX
    • Demo: Automatic Activity
    • Observation • Automatic activities run in thread of the web app • Exceptions in process roll back webapp transaction • Error message to the user
    • 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
    • Persisting State • Current state – Position in process graph – Variables – Timers • Waiting means – Persisting state – Committing transaction
    • A Basic Wait State
    • <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>
    • 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,...
    • Wait State Persistence 1. executionService .s tartProces s Ins tanceB yK ey(...) 1. Creates new execution 2. Starts executing from start activity 3. Execution arrives in s tate 4. Execution state will be saved 5. Transaction will be committed 6. jBPM service method will return
    • Wait State Persistence 2. Time goes by – Execution state remains in the DB
    • Wait State Persistence 3. executionService .s ig nalExecutionB yId(...) 1. Loads the execution 2. Takes an outgoing transition 3. Continues execution till next wait state 4. Stores execution updates 5. Commit transaction 6. signalExecutionById returns
    • A Basic Wait State transaction // e.g. in the button click code ProcessInstance processInstance = executionService .startProcessInstanceByKey("WaitState"); assertFalse(processInstance.isEnded()); String pid = processInstance.getId(); transaction // much later. e.g in another request or MDB executionService.signalExecutionById(pid);
    • 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
    • Demo: Wait S tate Activity
    • Process Execution Timeline
    • Transactional Control Flow Auto State Auto Auto Auto State Auto 1. executionService.startProcessInstanceByKey(…) Java Object: execution SQL: INSERT INTO JBPM4_EXECUTION …
    • Transactional Control Flow Auto State Auto Auto Auto State Auto 2. executionService.signalExecutionById(…) Java Object: execution SQL: UPDATE JBPM4_EXECUTION …
    • Transactional Control Flow Auto State Auto Auto Auto State Auto 3. executionService.signalExecutionById(…) Java Object: execution SQL: DELETE JBPM4_EXECUTION …
    • Concurrency • Parallel execution of activities • E.g. Order – Shipping – Billing • E.g. Loan – Sending loan money – Archiving contracts
    • Execution Concurrency
    • EventListeners • Attach POJO java code to process execution event • Hidden from the graph – For technical aspects
    • <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>
    • public class DoHidden implements EventListener { public void notify(EventListenerExecution execution) { ... } }
    • Asynchronous Continuations • Automatic activities in sequence • One takes a long time – E.g. pdf generation • Don’t block the client thread Job • async=“true” Executor pdf-g Transaction 1 Transaction 2
    • Timers • Actions – Take Transition – Event listeners • Also handled by JobExecutor • Business Calendar – 15 minutes – 4 bus ines s hours
    • Variables • HashMap associated to execution • Configurable type system • Scoping
    • Other Important Features • SEAM integration • Spring integration • Instance migration • Automatic upgrades
    • Summary • Fits ins ide your architecture • S upports multiple proces s lang uag es • Facilitates collaboration • jB PM has real value for real developers – Model process – Play with transactions – Write POJO code
    • Getting started  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
    • Q&A makes your work flow http://jbpm.org http://proces s developments .blog s pot.com http://jorambarrez.be/blog