WSO2 Enterprise Integrator 6 min

How to read properties in WSO2 BPS/WSO2 BPMN

Dusan Devic
Dusan Dević
Integration Consultant
Business Process Management scaled

Business Process ManagementIf you had the opportunity to work with WSO2 BPS or WSO2 BPMN, you’re familiar with the concept of variables. Just like in other programming languages, variable is in charge to hold some data and the system can make calculations and decisions based on such values. In this article I’ll show you how to read properties from the config file and to include them in your BPMN process definition. This can be very handy as, once you want to change something, it’s not necessary to recompile the code, redeploy the .bar file, even you don’t have to restart the product.

First of all, you need to create a new file call myconfig.properties and place it into EI-HOME/wso2/business-process/conf folder, with such content: 



Next, you’ll need to create new Maven project with such dependencies in your pom.xml:



Make sure you have the proper folder structure like for each maven project.  

Now create two files, as follows: 


import org.activiti.engine.delegate.DelegateExecution;

import org.activiti.engine.delegate.JavaDelegate;
import java.util.HashMap;
import java.util.Iterator;
import java.util.logging.Logger; 

public class ConfigApp implements JavaDelegate{     

      private static final Logger LOGGER = Logger.getLogger(ConfigApp.class.getName());
      HashMap<String, String> properties = new HashMap<String, String>();          

      public void execute(DelegateExecution execution) throws Exception {
            LOGGER.info("Config File Service Task");
            ConfigFile file = new ConfigFile();           

            this.properties = file.getProperties();                                                 

            Iterator entries = this.properties.entrySet().iterator();
            while (entries.hasNext()) {
                  HashMap.Entry entry = (HashMap.Entry) entries.next();
                String key = entry.getKey().toString();
                String value = entry.getValue().toString();                                  

                execution.setVariable(key, value);




… and ConfigFile.java:
import java.io.FileInputStream;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties;
import java.util.logging.Logger; 

public class ConfigFile { 

    private static Logger log = Logger.getLogger(ConfigFile.class.getName());
    HashMap<String, String> properties = new HashMap<String, String>();

     public ConfigFile() {

     public void readProperties(){

         Properties prop = new Properties();
        InputStream input = null; 

        try {
            Path currentRelativePath = Paths.get("");
            String absolutePath = currentRelativePath.toAbsolutePath().toString();
            log.info("Current relative path is: " + absolutePath);           

             input = new FileInputStream(absolutePath+"https://j8a3m7f3.rocketcdn.me/conf/myconfig.properties");

             // load a properties file

            Enumeration<?> e = prop.propertyNames();
            while (e.hasMoreElements()) {
                String key = (String) e.nextElement();
                String value = prop.getProperty(key);
                properties.put(key, value);

         } catch (IOException ex) {
        } finally {
            if (input != null) {
                try {
                } catch (IOException e) {


    public HashMap<String, String> getProperties(){
       return this.properties;



Once you build this, place the .jar file into EI-HOME/lib and restart the product. That’s the first part. The artifact you’ve created you’ll call from BPMN in order to read and initialize all the variables from myconfig.properties.

Open WSO2 Developer Studio and start creating new process.

Right after the START EVENT add new Service Task and make sure you’re calling the right package / class you’ve made in the previous step:

<serviceTask id="servicetask1" name="Get Config Stuff" activiti_class="com.yenlo.bps.config.ConfigApp"></serviceTask>

From there you can add your own workflow stuff. In this step system will execute the service task and that task will invoke your code and pull the variables. 
 As soon as you change the content of the properties file, new process instances will use updated values.

I hope this blog was helpful. If you have any questions regarding this blog, please ask them in the comment section below.


Microservices for the Enterprise

Get it now
We appreciate it
Care to share

Please select one of the social media platforms below to share this pages content with the world