Construct Your Enterprise App With BPMN 2.0 – DZone – Uplaza

On this brief tutorial, I’ll present easy methods to construct a enterprise utility with the Enterprise Course of Modelling Notation – BPMN. This method differs from the same old data-centric method as we deal with course of administration as an alternative of information processing.

Knowledge Processing vs. Course of Administration

Once we comply with the traditional method of constructing a Knowledge-Centric Enterprise Utility, we normally first design an information schema. The info schema defines what sort of knowledge could be managed. The appliance permits us to create new knowledge units, edit current knowledge, and, after all, seek for knowledge.

In a Course of-Centric Enterprise Utility, we as an alternative first attempt to reply the query of how knowledge ought to be processed to provide every actor the most effective entry to data to succeed in a selected enterprise objective. This sort of query turns into increasingly vital in at this time’s quickly evolving enterprise panorama. BPMN gives the right method to mannequin a workflow with its enterprise objectives from the start to the top. BPMN fashions could be created with numerous instruments just like the Open Supply BPMN designer Open-BPMN, for instance. 

The large benefit of BPMN is that it doesn’t solely give all stakeholders a transparent understanding concerning the course of, however a BPMN 2.0 Mannequin can be executed by an acceptable course of engine. This “low-code” or “model-driven” method results in a way more versatile approach to implement enterprise functions. After all, knowledge nonetheless performs an vital function, and workflow engines enable us to handle enterprise knowledge in numerous methods. So let’s see how this works.

Begin With a Enterprise Course of

Initially, we’ve to consider the enterprise course of behind our enterprise app. Earlier than we take into consideration knowledge, we must always deal with questions like:

  • Why do we want this type of data?
  • Who’s accountable to create or replace knowledge?
  • Which steps are essential to course of knowledge accurately?
  • What can we count on to occur subsequent?

As talked about earlier than, a enterprise course of defines the way in which to realize a concrete enterprise objective. In a BPMN mannequin, we will describe this fashion from its starting to the top. See the next instance of a easy “Proposal Creation Process”:


The BPMN mannequin defines a Begin- (inexperienced) and Finish- (purple) occasion to mark the start and finish of the method. An Exercise Ingredient (blue bins on this diagram) defines a single job within the enterprise course of. This can be a milestone to be reached. An occasion (blue circle) defines the transition into a brand new job or standing. An occasion could be triggered externally (e.g., “Order received from customer”) or by an actor (e.g., “Proposal created and submitted for review”). On this means, we get a sequence circulation – the workflow.

Enterprise Guidelines

Along with the sequence circulation, we will outline enterprise guidelines to implement further enterprise logic. For instance, we will outline {that a} Evaluate on this instance course of is just wanted for Proposals with a bid quantity over 1,000,00 EUR. For this, we will add an Unique Gateway with conditional flows to the diagram:

On this instance, the transition (Sequence Movement) between “Gateway-1” and the “Review Task” now comprises a situation; e.g.:

workitem.getItemValueDouble('quantity')>=1000.0

A BPMN engine can consider these sorts of situations by totally different script languages based mostly on the info offered within the workflow. The info can both be saved immediately within the course of occasion, or outlined by a reference to an exterior knowledge supply. There are a variety of extra components outlined within the BPMN 2.0 normal that enable the modeling even of far more complicated enterprise processes.

Run Your Enterprise Course of

Now let’s see how we will begin and management such a BPMN course of in an utility through the use of a BPMN engine. There are numerous BPMN engines accessible and a number of them are open supply. See the listing of awesome-workflow-engines maintained by @meirwah on GitHub.

Within the following, I exploit the Imixs-Workflow engine, which helps BPMN 2.0 and gives a Docker container that enables us to begin out of the field with out the necessity to write any code. With the Imixs-Microservice we will begin the BPMN Workflow engine in a container. Simply create a neighborhood docker-compose.yaml file with the next content material:

providers:
  imixs-db:
    picture: postgres:13.11
    surroundings:
      POSTGRES_PASSWORD: adminadmin
      POSTGRES_DB: workflow-db  
  imixs-app:
    picture: imixs/imixs-microservice:newest
    surroundings:
      TZ: "CET" 
      LANG: "en_US.UTF-8"  
      POSTGRES_USER: "postgres"
      POSTGRES_PASSWORD: "adminadmin"
      POSTGRES_CONNECTION: "jdbc:postgresql://imixs-db/workflow-db"
    ports:
      - "8080:8080"

Begin the service with:

$ docker compose up

The service begins with a brief welcome web page at http://localhost:8080 and gives a REST interface at http://localhost:8080/api/openapi-ui/index.html. This REST API person interface permits us to check numerous strategies to begin a workflow or to course of current ones.

Add Your Mannequin

First, we have to add our mannequin. For this, we will use the curl command and submit our BPMN file to the REST Service endpoint:

$ curl --user admin:adminadmin --request POST 
-Tmy-model.bpmn http://localhost:8080/api/mannequin/bpmn

Or we will use the REST API UI to submit the mannequin on the useful resource /api/mannequin/bpmn/.

You may obtain the check mannequin from GitHub otherwise you create a brand new file my-model.bpmn with the next content material:



  
    
      
    
    
      
      
      
    
    
      
      
      
      
      
    
    true
  
  
    
      
    
    
    
    
  
  
    
  
  
    
      
        Task_2
        IntermediateCatchEvent_1
        StartEvent_1
        Task_1
        IntermediateCatchEvent_7
        Task_4
        EndEvent_1
        IntermediateCatchEvent_8
        
        TextAnnotation_2
        gateway_R0B00Q
        gateway_7zm0sw
      
    
    
      
        
          topic ]]>
        
        
          true
        
        
        
      
      
      sequenceFlow_fCuqCw
      sequenceFlow_7jbDFQ
    
    
      SequenceFlow_12
      
    
    
      
        
          $Editor]]>
        
        
          20]]>
        
        
          false
        
        
        
        
      
      <b>Submit</b> a brand new ticket
      SequenceFlow_11
      SequenceFlow_3
      
    
    
      
    
    
      
        
          topic ]]>
        
        
          true
        
      
      SequenceFlow_12
      
      sequenceFlow_BYx0Eg
      sequenceFlow_O00HWA
    
    
      
    
    
      SequenceFlow_1
      
    
    
      
    
    
      
        
          topic ]]>
        
        
          
        
      
      Create a brand new ticket
      SequenceFlow_1
      SequenceFlow_11
      sequenceFlow_jspJig
    
    
      
    
    
      
        
          
        
        
          false
        
        
        
          
        
      
      
      sequenceFlow_Wn3NGw
      sequenceFlow_BYx0Eg
    
    
      
        
          namcurrentEditor]]>
        
        
          false
        
        
        
          
        
      
      
      sequenceFlow_GNxY5A
      sequenceFlow_jspJig
    
    
      
      
    
    
      
      sequenceFlow_fCuqCw
      sequenceFlow_GNxY5A
      sequenceFlow_Wn3NGw
    
    
      
    
    
      
    
    
      
    
    
      
    
    
      
    
    
      
      SequenceFlow_3
      sequenceFlow_7jbDFQ
      sequenceFlow_O00HWA
    
    ">>=1.000" sourceRef="gateway_7zm0sw" targetRef="Task_2">
      
      =1000.0]]>
    
    <1.000" sourceRef="gateway_7zm0sw" targetRef="Task_4">
      
    
  
  
    
      
        
      
      
        
      
      
        
        
          
        
      
      
        
        
          
        
      
      
        
      
      
        
      
      
        
      
      
        
        
          
        
      
      
        
        
          
        
      
      
        
        
          
        
      
      
        
        
          
        
      
      
        
      
      
        
        
        
      
      
        
        
        
      
      
        
        
        
      
      
        
        
        
      
      
        
        
        
        
      
      
        
        
          
        
      
      
        
        
      
      
        
        
      
      
        
        
        
      
      
        
        
      
      
        
        
      
      
        
        
          
        
      
      
        
        
      
      
        
        
        
        
      
    
    
      
    
  

The standing of all accessible fashions could be verified on the REST API endpoint, http://localhost:8080/api/mannequin

Word: I exploit the person ID admin with the password adminadmin right here. Extra customers with totally different roles are outlined by this service. Discover the main points on the GitHub repo linked earlier.

Begin a New Course of Occasion

Now that the service is up and operating, we will begin our first course of occasion. For this, we simply must submit an XML doc containing the mannequin data and our enterprise knowledge. We will use the next REST API Endpoint to submit a brand new course of occasion: POST: /api/workflow/workitem.


    proposal-en-1.0
    1000
    10
    
        My first propsal...
    
    
        500.0
    

Once more, you possibly can submit the info immediately with the REST API UI. On this instance, I outline the modelversion, the preliminary job and the occasion to be processed, in addition to some customized enterprise knowledge (topic and quantity).

The workflow engine mechanically executes the info in accordance with our uploaded BPMN mannequin and returns a consequence object. To confirm the consequence we will examine the tasklist with all course of cases created by the person admin at http://localhost:8080/api/workflow/tasklist/creator/admin

As you possibly can see, the workflow engine has processed our knowledge and utilized the standing Accomplished to our new workflow occasion. This was as a result of the quantity was under 1.000,00. To check our enterprise logic we will now change the quantity to a price higher than 1.000,00 which can begin one other new course of occasion within the standing Evaluate in accordance with our enterprise guidelines.

We will now simply change the method logic and add new duties or enterprise guidelines. All we’ve to do is to add the brand new model of the BPMN mannequin. No redeployment of the appliance is required. 

To replace the info of an current course of occasion we will submit the info along with the $uniqueid and the corresponding occasion from our mannequin:


    8333c61c-b973-4591-aabf-ec92bd59d74b
    10
    
        Baker Avenue 221b.
    

The sector $uniqueid is returned by the primary creation of a brand new workflow occasion and is a reference for additional processing steps. On this instance, I solely present the reference ID, an Occasion ID, and a few new knowledge. The Workflow engine will confirm the request and the occasion in accordance with the assigned mannequin. This ensures that the info is all the time processed in accordance with our enterprise course of! We will additionally use the $uniqueID to fetch the info from the workflow engine – e.g., to show the info in an internet interface.

How To Combine BPMN Into Your App

On this tutorial, I’ve intentionally omitted the design of an internet interface as a result of I needed to deal with the enterprise logic. When utilizing a REST API – as on this instance – the workflow engine could be built-in into an utility simply through the use of totally different frontend applied sciences. As well as, there are sometimes different methods to attach a BPMN engine to your personal utility relying on the framework utilized by the engine. For instance, a number of open-source engines are based mostly on Java and could be built-in by widespread construct instruments like Maven or Gradle.

For instance, you possibly can combine the Imixs Workflow engine right into a Jakarta EE app with the next dependencies:

...
    
        org.imixs.workflow
        imixs-workflow-engine
        ${org.imixs.workflow.model}
    
    
        org.imixs.workflow
        imixs-workflow-index-lucene
        ${org.imixs.workflow.model}
    
...

Name the engine inside your code utilizing the CDI Framework like this: 

@Inject
personal org.imixs.workflow.engine.WorkflowService workflowService;

ItemCollection workitem=new ItemCollection().mannequin("proposal-en-1.0").job(1000).occasion(10);
// assign some enterprise knowledge...
workitem.setItemValue("amount",500.0);
// course of the workitem
workitem = workflowService.processWorkItem(workitem);

This code instance is the same as the REST API name within the instance above.

Knowledge Integration

As talked about earlier than, one other side is the way in which you deal with your enterprise knowledge. In my instance code, I embedded the enterprise knowledge immediately into the workflow occasion, so no exterior database was wanted.

However after all, in some eventualities, it might be helpful to simply retailer a reference to an exterior dataset and maintain the enterprise knowledge in a separate database.

Or you could reference the workflow occasion out of your knowledge processing utility by extending the info schema.

Within the final two eventualities, we additionally want to supply an information service to have the ability to course of the beforehand talked about enterprise logic within the course of engine. All trendy BPMN engines present interfaces to attach an information supply with the method logic. 

Conclusion

In abstract, incorporating BPMN 2.0 into your enterprise utility gives a structured and environment friendly approach to deal with your enterprise processes. The flexibility to visually course of fashions not solely simplifies the design and administration of complicated workflows but in addition enhances collaboration throughout technical and non-technical groups. Through the use of instruments like Open-BPMN or Imixs-Workflow, you possibly can simply implement BPMN 2.0 requirements, making certain that your enterprise functions are each scalable and adaptable. Embracing BPMN 2.0 can result in extra organized, clear, and efficient enterprise operations, setting the stage for higher success and progress.

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version