Skip to Main Content

How to Use Java Service Tasks in WSO2 BPS

WSO2 Business Process Server is an open-source middleware with the necessary features to provide for an efficient management of business processes. It enables developers to easily deploy business processes written in standard WS-BPEL or BPMN 2.0 execution languages. It also serves as a business process management and hosting environment for service-oriented architecture (SOA).

WSO2 Business Process Server is powered by Activiti and Apache ODE, and is licensed under the Apache License Version 2.0.  It executes business processes written in standard WS-BPEL or BPMN 2.0. 

What is BPMN? 

Business Process Model and Notation (BPMN) is a standard graphical notation that facilitates business process modeling in a workflow format.  It enables business analysts to develop processes, which are created by technical personnel before being implemented by management. 

What are Java Service Tasks? 

Java Service Tasks are used to invoke an external Java class. It enables the user to directly add the task to the process workflow, automatically invoke the external class to query and obtain the response, and carry out the workflow according to the response of the server.

For example, authorization is required to upload a document to a content manager in a workflow. It is therefore necessary for the document to be automatically uploaded using the content management API once the action is authorized.

How to create a BPMN model

WSO2 Integration Studio IDE will be used to create our BPMN model. 

1. Once the IDE has downloaded, create a BPMN-type project by clicking “Create New BPMN”.

2. An end-to-end workflow diagram should then be created. In this case, the Java Service Task will include the process of automatically uploading said file to the content manager. 

3. When creating the Java class, we must ensure that the org.activiti.engine.delegate.JavaDelegate interface is included. 

4. In the Java Service Task, the class name must be indicated in the Main config option.

5. The following option must be selected in order to deploy the WSO2 BPS components:

6. The artefacts are displayed in the deployment folder once generated. 

7. The .jar file must be moved to the <WSO2-EI-HOME>/lib folder.

8. The .bar file must be deployed in the WSO2 BPS management console via the following URL:

https://localhost:9445/carbon/

In the console, select the “Add -> BPMN” option.

Select the previously created .bar file and click  “Upload” to complete the process. 

 

If the file deploys correctly, the following text will appear: 

You can see that some files are automatically uploaded to the content manager upon execution of the workflow and during task approval. 

Conclusions

As we have seen, Java Service Tasks are extremely useful since they enable the user to directly add a task to process workflow, automatically invoke the external class to query and obtain the response, and carry out the workflow according to the response of the server. In this case, the response will be received via the content manager upon confirmation of file upload.