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.
- 1. BPM Service Integration Example Project
- 2. Booting Environment
- 3. Integration Engineering
- 4. Service Integration
- 5. iSaaS Service Integration
- References / Links
- Maintainer
- License
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:
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:
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.
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:
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:
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.
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.
Define (or change) the service task implementation by using the 2. Service Task REST with Body
template.
This template pre-defines to Camunda HTTP Connector
4, which can be inspected by switching to the Connector
tab.
However the
Camunda HTTP Connector
4 can also be configured manually without using a template.
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:
Now you are ready to deploy your process and test if it works as expected.
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.
The implementation can be realised in a similar way as instructed in the 4. Service Integration section above.
1 Element Templates
- https://docs.camunda.org/manual/latest/modeler/camunda-modeler/element-templates
- https://github.com/camunda/camunda-modeler/tree/master/docs/element-templates
2 Unit testing
3 API Debugging and Testing
- https://www.getpostman.com/tools#debug
- https://blog.getpostman.com/2014/03/07/writing-automated-tests-for-apis-using-postman
4 Camunda HTTP Connector