lundi 31 août 2009

Jbpm 4 Tutorial: JBPM 4, which is BPMN compliant, simplifies his programming model

Now that, JBPM, has passed the difficult age of childhood, and that it is a very popular BPM framework, his adopted father RedHat (JBoss owner) has decided to change everything: programming model and schema database.

Its goal: to simplify the programming model, to increase the number of adoptions and to reinforce the shift to the PVM (Processs Virtual Machine).

Programming model revised

This version 4 JBPM is a complete rewrite from version 3: while retaining the basic principles: open source, 100% Java, concept of process, storage of instances and definitions of process into the database, based on Hibernate, assisted by IDE.

Many users jbpm 3 will agree with me that certain APIs are difficult and that they needed to write complex queries Hibernate, leading to several problems.

With the mixture of concepts in JBPM 3 APIs, methods are scattered in classes JbpmContext, GraphSession or TaskManager.

The JBPM 4’s team has rationalized all BPM concepts, around the API ProcessEngine.

Any use of JBPM starts by acquiring the services desired from ProcessEngine: the central node of BPM by RedHat.

Use the API as needed

  • RepositoryService: allows to manage static data processes: deployment, activation / deactivation request
  • ExecutionService: exposes runtime execution operations (for process instances): start executing process instances, manage variables, retrieve instances, etc.
  • TaskService: it is the modeling of human interaction: everything to manage tasks: create, search, assign, complete..

clip_image002[4]

Two other APIs have made their appearances:

  • HistoryService: In JBPM 4 there is a clear separation between the runtime and data archiving. This service provides statistical measurements and calculations performed by the engine. This API has no relation with the runtime: it discusses the history and times past. Through this service the historical data (instances completed, work performed) can be searched and presented a statistical study Later.
  • ManagementService: This API is intended for tools to manage processes telque famous JBPM console.

Database Schema simplified

clip_image003[4]

clip_image004[4]

Hibernate mapping is as follows

1:            <mapping resource="jbpm.repository.hbm.xml" /> 
2: <mapping resource="jbpm.execution.hbm.xml" />
3: <mapping resource="jbpm.history.hbm.xml" />
4: <mapping resource="jbpm.task.hbm.xml" />
5: <mapping resource="jbpm.identity.hbm.xml" />


A first test of the new version of JBPM: Version 4 JBPM



It is a simple example of a process containing two steps: one to display a message and another to launch a backup

JBPM 4 uses the notation BPMN 2.0



clip_image001



The XML version of this process definition:



1:  <?xml version="1.0" encoding="UTF-8"?> 
2: <process name="seconde_hello_de_OXIA" xmlns="http://jbpm.org/4.0/jpdl">
3: <start g="24,72,80,40">
4: <transition to="afficherMessage"/>
5: </start>
6: <java class="com.oxia.att.jbpm4.exemple.AfficherMessage" g="120,68,138,56" method="afficherMessage" name="afficherMessage">
7: <transition to="lancerBackup"/>
8: </java>
9: <end g="165,267,80,40" name="fin"/>
10: <state name="lancerBackup" g="143,147,92,52">
11: <transition name="to fin" to="fin" g="-30,-18"/>
12: </state>
13: </process>


The java class for Handling the message (very very simple ) :



1:  package com.oxia.att.jbpm4.exemple; 
2: public class AfficherMessage {
3: public void afficherMessage() {
4: System.out.println("****** début de passage par un Etat");
5: System.out.println(" Bonjour de OXIA!");
6: System.out.println("****** fin de passage par un Etat ");
7: }
8: }


To test this process in a Java project (very basic steps )



1:  public static void main(String[] args) { 
2: // get the ProcessEngine instance
3: ProcessEngine processEngine = new Configuration().setResource("oxia.att.jbpm.cfg.xml").buildProcessEngine();
4: // get one instance of the RepositoryService
5: RepositoryService repositoryService = processEngine.getRepositoryService();
6: // Deploy the process definition du processus
7: repositoryService.createDeployment().addResourceFromClasspath("com/oxia/att/jbpm4/exemple/first_Jbpm_Sample.jpdl.xml").deploy();
8: // get one instance of the ExecutionService
9: ExecutionService executionService = processEngine.getExecutionService();
10: ProcessInstance processinstance = executionService.startProcessInstanceByKey("hello_de_OXIA");
11: System.out.println( processinstance.getId());
12: System.out.println( processinstance.getState());
13: }


The Result:



1:  ****** début de passage par un Etat 
2: Bonjour de OXIA!
3: ****** fin de passage par un Etat
4: hello_de_OXIA.6
5: ended


Conclusion



RedHat has restructured JBPM 4 around a simplified API and a clear pattern of effective database.



Reste à vérifier les annonces concernant l’amélioration des performances : grâce au nouveau schéma de base de données, la récriture des classes de bases de Job executor et activities et l’amélioration de la gestion de la concurrence.



It remains to check the listings for improving performance: thanks to the new schema database, the rewriting the basic classes of Job executor and activities and improving concurrency management.









(fr)




  • Autre sujets



    1. Un peu de monitoring Métier (BAM) avec JBPM et SeeWhy (event-driven business intelligence )



    2. Comment modéliser un processus métier avec JBPM : exemple “gestion des entretiens”



    3. Quelle est la différence entre JBPM et Intalio ?



    4. Graph Oriented Programming (GOP) avec JBPM



    5. BPM & Moteur de workflow : l’offre open source



    6. La version 4 de JBPM prend le virage de BPMN



    7. Jbpm 4 Tutorial : JBPM 4 a simplifié son model de programmation et a confirmé l’orientation BPMN


  • 4 commentaires :

    Anonyme a dit…

    hello,

    it's really a good example to start !please i would like to know if jbpm generates automatically forms to enter data or not like in Bonita

    Labo_R&D_IA_Tunisie a dit…

    yes JBPM offers the ability to generate forms, use jBPM Studio ...

    Anonyme a dit…

    hello,

    Thank you ,yes i tired to do that and it worked :)) ,can i use jbpm with netbeans ?if yes how can i do that ?

    Labo_R&D_IA_Tunisie a dit…

    I do not think there is a netbeans module equivalent to Jboss JBPM Eclipse studio. But if it deals only with the JBPM engine part that does not depend on the IDE

    Enregistrer un commentaire

    Architecte SOA & Professionnel Open Source Headline Animator

     
    Khaled BEN DRISS
    Cloud Computing, SOA et Web 2.0 : Des sujets techniques sur SOA et l'Open Source : de Java & .Net, PHP5, Symfony, à SaaS / PaaS en passant par Azure, google appengine, le BPM, la Modélisation et d'autres sujets du coté du serveur et cloud computing.