WSO2 Micro Integrator : Launch & Deploy
Today we are going to see a basic post on how to launch and deploy an application on a WSO2 Micro Integrator, MI. The idea is to create a basic example on which we can build more complex examples in future posts.
The Micro Integrator is the evolution of the WSO2 Enterprise Integrator. It is the solution they propose to bring the Enterprise Service Bus world closer to microservices. Allowing the deployment of integrations with containers in a minimum time, a low memory footprint and in an agile way.
For the example we will use:
- Micro Integrator 4.0.0
The first thing will be to create our application that for this example will be a simple mock. If you don’t have much experience with WSO2 the best is to use the Integration Studio. Which is an embedded eclipse but with multiple qualities:
- Graphical engine that helps you in the creation of integrations.
- Templates to perform certain actions.
- Step-by-step guides to configure certain components.
- Allows you to select the artifacts to deploy in a simple way.
My personal opinion about it, is that it has improved a lot, over the years and if you don’t have enough experience it can be very helpful. But if you have experience and a good Maven archetype, which you can make yourself, with a simple text editor you can achieve the same, in a faster and more agile way.
That’s why when we put code related to WSO2 integrations we will always show the XML code and not the Integration Studio’s own graphics.
With it we are going to create a simple API that has two resources that allow us to always return the same result:
This API, we will include it in a CAR which is the package format for WSO2 integrations.
Next we will see how to deploy it in a docker image. But in order to download the MI image, we will need a WSO2 account, free of charge, and log in to its docker hub.
docker login docker.wso2.com -u firstname.lastname@example.org
This image will be included in a basic docker-compose in which we will be able to include other dependencies in future posts.
- subnet: "172.16.238.0/24"
JAVA_OPTS: "-DenableManagementApi=true -Duser.timezone=Europe/Madrid"
A couple of notes about this file:
- With the enableManagementApi parameter we can enable the management API.
- The deployment.toml file is the Micro Integrator configuration file. For this case we have not made any change on the default file, but it is normal to modify it and that is why we have added it in a volume.
Now with this docker-compose we will see different ways to be able to deploy the CAR.
1. Configure a volume where the drop-down is located: It allows us to indicate at startup time the integrations that we want to deploy.
2. Start the IM and pass the drop-down to it: Similar to the previous step, but it allows us to deploy applications with MI already running. This is especially useful when we are developing.
docker cp wso2-basic-example_1.0.0.car wso2mi:/home/wso2carbon/wso2mi-4.0.0/repository/deployment/server/carbonapps/
3. Create a Dockerfile with the CAR: This option will be ideal when we have our stable integration and we want to deploy it in productive environments.
First we build the Dockerfile
COPY wso2-basic-example_1.0.0.car /home/wso2carbon/wso2mi-4.0.0/repository/deployment/server/carbonapps/
Then we build the image
docker build -t deesebc/book-api-mi .
And for last, we runt it
docker run -it -p 8290:8290 -p 8253:8253 -p 9164:9164 --name micro-integrator deesebc/book-api-mi
4. API Management: Although it is indicated in the documentation as a possibility, as of 03/2022 it is only possible as a paid update of the IM.
Once we have started it we will be able to consult our API:
curl --location --request GET 'http://localhost:8290/book/mock'
curl --location --request GET 'https://localhost:8253/book/mock'
The other enabled port, 9164, will be the one that gives us access through HTTPS to the management API.
I hope it has been useful, and as always if you want the complete code you can see it here.