Skip to content

This is an example project for showing the service integration on the Camunda workflow engine.

License

Notifications You must be signed in to change notification settings

fhnw-bpm/bpm-service-integration-example

Repository files navigation

BPM Service Integration Example

License Deploy to Heroku

This example illustrates how service integration can be realized with Camunda and the help of Postman without touching Java.

This service integration guide is a follow-up of the BPM Workflow Examplehttps://github.com/fhnw-bpm/bpm-workflow-example and is relying on the BPM API Example.

Contents:

1. BPM Service Integration Example Project

Download this repository and extract the files - similar as shown here:

Please note that the animation is showing a different repository.

This repository is a copy of the digibp-camunda-template repository on GitHub and is based on the following structure:

2. Booting Environment

Run your implementation of the BPM API Example on port 8081.

Then compile and run this workflow microservice project on the default port 8080.

Finally, open the pizza-service-technical-service-integration.bpmn file stored under src\main\resources\modelling of this project:

pizza-service-technical-service-integration

3. Integration Engineering

In engineering, especially in software development, software testing is a fundamental principle. Developers are writing tests before they start with their actual implementation to specify what the application has to fulfil - this is referred to unit testing2.

It is therefore not surprising that testing is not excluded as well when using APIs3 and integrating services. Consequently, it is recommended to write API tests prior doing a service integration into a BPMN workflow too.

Step 1: Import Camunda Environment

As mentioned above testing is an essential part of engineering. And when testing, you are trying the replicate the reality within a testing environment. Therefore DigiBP provides you with a Postman environment reproducing the Camunda engine and the Camunda HTTP connector extension. You can import that Postman environment and a collection as a blueprint by clicking on the following button:

Import in Postman

This feature enables you to write test with an environment which makes you feel as you would write directly within Camunda.

And yes for the techies, eval is evil, but it is currently the only way to integrate predefined JavaScript code into Postman.

For the following both endpoint paths you will find in the imported collection a request template in Postman, where you should write a pre-request script each:

2018-04-23_20h25_12

Step 2: Pre-request Scripts

Please note that this step is an iterative task for both service tasks in the BPMN model.

In the pre-request script tab, you are going to write the script for the Camunda input parameters. In Postman the resulting data of the script is going to be placed into the body of the request.

Switch to the body tab and set the following postman variable (if you imported the blueprint collection above, it is already there: {{payload}}.

Now it is time that you write your pre-request script by using this template:

// Connector-START • Camunda HTTP Connector JavaScript emulation:
eval(pm.environment.get("camunda"));
// Connector-END

// Test-Data-START • Initialise process variables, and (optionally) business key and/or process id:

pizzaType = "";
/* further process variables here */
execution.setBusinessKey("case-001");

// Test-Data-END

// Service-Task-Input-START • Camunda HTTP Connector Input Parameter payload Script:
out = JSON.stringify({
  "businessKey": execution.getBusinessKey(),
  /* further JSON data here */
  "pizzaType": pizzaType
});
// Service-Task-Input-END

// Body-START • Postman Body {{payload}}:
payload.set(out);
// Body-END 

First emulating the Camunda environment including the process variables and workflow data by defining them between // Test-Data-START and // Test-Data-END.

Keep in mind to name your process variables the same way as defined in tor process model.

Then you are going to write they actual part, which will be embedded into the BPMN model. You are going to produce the payload containing the workflow data serialised as a JSON object by defining it between // Service-Task-Input-START and // Service-Task-Input-END.

If you did everything as instructed, you should receive a 201 Created after pressing the Send button in Postman.

4. Service Integration

Finally, integrate your services into your process model as described in the subsequent steps and shown in the following animation:

Please note that the animation is showing a different process.

Step 1: HTTP Connector and Template

Define (or change) the service task implementation by using the 2. Service Task REST with Body template.

This template pre-defines to Camunda HTTP Connector4, which can be inspected by switching to the Connector tab.

However the Camunda HTTP Connector4 can also be configured manually without using a template.

Step 2: Input Parameter

Copy the Postman pre-request script part between // Service-Task-Input-START and // Service-Task-Input-END and paste it to the Script field of the Camunda HTTP Connector input parameter payload.

Do that for every service task:

2018-04-23_20h19_45

Step 3: Deployment

Now you are ready to deploy your process and test if it works as expected.

5. iSaaS Service Integration

Please use the following link to a Zapier iSaaS integration of the Gmail API to send an electronic receipt: https://hooks.zapier.com/hooks/catch/2050261/fzoaaq/

Please note that the Zap is switched of to avoid email spam.

To implement the send receipt message task as shown as follows, please use the send receipt request of the imported Postman collection.

pizza-service-technical-service-integration-isaas

The implementation can be realised in a similar way as instructed in the 4. Service Integration section above.

References / Links

1 Element Templates

2 Unit testing

3 API Debugging and Testing

4 Camunda HTTP Connector

Maintainer

License

About

This is an example project for showing the service integration on the Camunda workflow engine.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages