WSO2 Enterprise Integrator 7 min

Doing a simple scripted setup of WSO2 Enterprise Integrator

Rob Blaauboer
Rob Blaauboer
Integration Consultant & WSO2 Trainer
Code laptop

Code-laptopThere are several situations where you want or need to set up WSO2. As a trainer, I do this more than I guess almost anybody else. Although making minor changes to WSO2 is not that much work. I’m talking about changing the port offset, changing host names or changing other parameters that will slightly alter the product. It would be nice to have a semi-automated tool that will allow me to do that.


If you want to do, let’s say, the deployment of a number of servers using a standard set up. Investing in a tool such as Ansible is a good idea, especially when you do this often. Ansible is a very powerful tool that allow you to manipulate WSO2 products and its installation but it does have a learning curve.  Before you can write a playbook or even adapt a playbook that you get from someone else you need to make sure that you know what Ansible is capable of and how you need to manipulate Ansible in order to get the right results.


So, I was thinking, isn’t there an alternative that allows me to quickly make changes to a WSO2 product in order to set it up but doesn’t require a lot of learning and doesn’t require a third-party tool like Ansible? And actually, while I was tinkering with the distributed deployment setup of the API Manager with some help of my colleague Yonathan, we came up with a solution.

The solution is a combination of basic command line tools like zip, copy, move and SED.  SED is a stream editor that allows you to make changes to a file.  And as the configuration files of WSO2 at this moment are mostly captured in XML files, using SED to manipulate these files is good fit.

What I’m going to show you in this blog is a way to use a combination of tools to set up a very simple enterprise integrator with the port offset and hostname as well as changing the database to MySQL.

In order to test this, we could set up a enterprise integrator using vagrant and virtual box. But I created a Windows setup that you can easily change to your liking and will run on Linux too (with some modifications, as a shell file).

Windows setup

My Windows environment is very simple.  I’ve created the directory with a zip file of the enterprise integrator version 6.2.0 and the version that I unzipped manually.  In this directory, I’ve copied the JDBC connector as well and created the Windows batch file that I’m going to use to do the configuration.

windows setup wso2 ei

I’m not referring to any absolute paths (from the root to the directory) but rather relative paths from this directory so any commands within the batch file will just refer to configuration files within the directory of the enterprise integrator.

The script

The script to change the configuration-simple scripted setup wso2 ei

The script to change the configuration

I also include the script as text since an image is hard to copy and quite useless.

So, what do we do in the script? Actually, it’s quite simple. With SED we can manipulate certain parts of the XML file.  In the first line, we actually change whatever is between the XML offsets tags to 100.  The word graph with the square brackets around it and the Asterix (*) signify any characters between the tags.  So basically “everything between the brackets” Then it will be replaced by the number hundred.  At the end of the line you will find the file name in which this needs to take place.

echo Offset in Carbon to 100

sed -i "s|<Offset>[[:graph:]]*</Offset>|<Offset>100</Offset>|g" wso2ei-6.2.0/conf/carbon.xml

echo master datasources change to mysql

When we want to exchange the embedded H2 database for my SQL we need to make a number of changes to the master data sources file that we can find in the data sources directory.  In order to make it semi-future proof we included a new piece of regular expression, namely that we want changes to be made within the data source XML tags.  In this case it will only change the URL in this data source environment.  Why do I say make it semi-future proof? Well the simple the master data sources configuration file might house multiple data sources that will all have a data source tag around it.  In this case with a setting that is out-of-the-box enterprise integrator there is only one tag in use in this file and therefore we can take this approach and it will work.

sed -i "/<datasource>/,/</datasource>/ s|<url>[[:graph:]]*</url>|<url>jdbc:mysql://localhost:3306/carbondb</url>|g" wso2ei-6.2.0/conf/datasources/master-datasources.xml

sed -i "/<datasource>/,/</datasource>/ s|<username>[[:graph:]]*</username>|<username>root</username>|g" wso2ei-6.2.0/conf/datasources/master-datasources.xml

sed -i "/<datasource>/,/</datasource>/ s|<password>[[:graph:]]*</password>|<password>root</password>|g" wso2ei-6.2.0/conf/datasources/master-datasources.xml

sed -i "/<datasource>/,/</datasource>/ s|<driverClassName>[[:graph:]]*</driverClassName>|<driverClassName>com.mysql.jdbc.Driver</driverClassName>|g" wso2ei-6.2.0/conf/datasources/master-datasources.xml

After making changes to the URL username password and driver class with made enough changes for this very simple example to work.  If you want to extend this example you might need to put in a little bit more work depending on the set up that you would like to do, for instance a distributed deployment of the API manager will certainly need more lines because there are more databases but also some changes to the regular expressions used within the scripts.


What I would normally do, is a set up where I create a database in my SQL, run the scripts from the DB scripts directory inside the enterprise integrator and make sure all of the permissions are set in order to make it work.  But there is another way that is more quick and dirty that will also work.  In this case I’m just using the command line of MySQL to create the carbon DB database that we are going to use for the user and registry data.  The create database command will create an empty database with no tables but it is enough for WSO2 to work with.

There is a parameter that you can use when you’re starting up the product for the first time which is -Dsetup. This command will actually create all of the tables by running the script for the database and will actually save us one step in setting up all of this.  This only works of course if you copy to JDBC connector file in the lib directory in the enterprise integrator.

echo create database in Mysql
mysql -u root -proot -e "create database carbondb character set latin1";
echo copy the JDBC connector
copy mysql-connector-java-5.1.38-bin.jar wso2ei-6.2.0lib

Now the only thing we need to do is to start up enterprise integrator using the aforementioned command and parameter.

echo start EI
wso2ei-6.2.0/bin/integrator.bat -Dsetup

As you can see from the home screen of the enterprise integrator we are now running on MariaDB with a port offset of 100.

Home screen WSO2 EI running MariaDB

Home screen WSO2 EI running on MariaDB 2


In this blog, I’ve showed you a way to manipulate some of the configuration files of the WSO2 Enterprise Integrator. This is not a replacement for any configuration or provisioning tool like Ansible or Vagrant or something else but just a simple way of making some quick changes when you want to deploy something.  The stream editor SED is quite complex but luckily there are many samples online that you can use and change and create a version of this that will help you deploy WSO2 products. 

You can find both the Windows and the Linux versions of the scripts on the Yenlo Bitbucket account: https://bitbucket.org/RobWSO2/stream-editor-example-wso2-ei-6.2.0/src/master/

If you have any questions about this blogpost contact us via the comments section below. View also our WSO2 Tutorialswebinars or white papers for more technical information. Need support? We do deliver WSO2 Product SupportWSO2 Development SupportWSO2 Operational Support and WSO2 Training Programs. 

Full API lifecycle Management Selection Guide

whitepaper hero
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