Routing requests based on message content
This is a 5-minute guide to give you a quick overview of how WSO2 EI mediates and routes messages from a front-end service (client) to a back-end service.
Before you begin,
Go to the WSO2 Integration product page, click Download → Previous Releases. You can now download WSO2 EI 6.5.0 version.
Let's call the installation location of your product the
Note that if you used the product installer to install your product, the
<EI_HOME>is located in a place specific to your OS as shown below:
OS Home directory Mac OS
- If you are on a Windows OS, install cURL. For more information, see the cURL Releases and Downloads.
Let's get started!
Configuring WSO2 EI
Start the WSO2 ESB profile.
The WSO2 EI product consists of many profiles. The ESB profile is used to manage short-running and stateless integrations. For more information, see WSO2 EI Overview.
Open the ESB profile's Management Console using
https://localhost:9443/carbon, and log in using admin as the username and the password.
The Management Console provides a UI to configure WSO2 EI. WSO2 Carbon is the core platform on which WSO2 middleware products are built.
SampleServicesCompositeApplication_1.0.0.carfile from GitHub.This file is a Carbon Application Archive (CAR file) containing the integration artifacts you will use in this tutorial, including:
- An API resource, which acts as the endpoint that accepts incoming requests from a client, routes them to the back-end service for processing, receives a response from the service, and sends the response back to the client.
- The back-end service that processes the appointment requests.
- A Switch Mediator to route messages (based on the message content) to the relevant HTTP Endpoint defined in the ESB.
SampleServicesCompositeApplication_1.0.0.carfile as follows:
- On the Main tab of the Management Console, go to Manage > Carbon Applications, and click Add.
Click Choose File, select the
SampleServicesCompositeApplication_1.0.0.carfile that you downloaded and click Upload.
Refresh the page to see the Carbon application you just added in the Carbon Applications List screen.
- Download the back-end service from GitHub. This will process appointment requests and copy it to the
<EI_HOME>/wso2/msf4j/deployment/microservicesdirectory. The back-end service is now deployed in the MSF4J profile of WSO2 EI.
Start the MSF4J profile. The back-end service is now started!
Sending requests to WSO2 EI
We are now ready to request a doctor's appointment at the Grand Oak Community Hospital.
Create a JSON file named
request.jsonwith the following payload, which specifies the details that are required by the back-end service to make the appointment: patient information, doctor name, hospital name, and appointment date.
If you want to request a different hospital, you can specify one of the following hospital names instead.
clemency medical center
pine valley community hospital
Open a terminal, navigate to the directory where you have saved the
request.jsonfile, and execute the following cURL command.
This command sends the JSON payload you created in the previous step to the API resource (
http://localhost:8280/healthcare/categories/surgery/reserve), which was included in the CAR file you uploaded. The API resource contains the logic for routing appointment requests to the back-end service.
You get the following response:
Now, check the terminal window and you see the following message:
INFO - LogMediator message = Routing to grand oak community hospital
Congratulations, you have successfully completed this guide!
In this tutorial, you have seen how you can create a request payload and send it to an endpoint in WSO2 EI, which routes the message to a back-end service and then sends a response back to the client.
Exposing a datasource as a service
Sending messages securely
Defining a BPMN process
Other WSO2 EI capabilities
- In comparison with the conventional ESB profile, the start-up time of the Micro Integrator profile is considerably less, which makes it container-friendly, and thereby, is ideal to use it for microservices in a container-based environment. For more information, try out the Sending a Simple Message to a Service Using the Micro Integrator tutorial.
- Work with WSO2 EI connectors.
- All the CAR files that were used in this tutorial were developed using WSO2 EI Tooling. You can try it out by following the tutorials listed under Integration Tutorials.
- Use WSO2 EI Analytics to analyze the mediation statistics. For more information, try out the following tutorial: