SOLACE + WSO2 MI
Greetings, Tech Enthusiasts! 🚀 Today we are going to dive into our latest blog where we unravel the intricacies of configuring Solace as a message broker in WSO2 Micro Integrator (MI)
Pre-requisites
Configure Solace
To begin, let’s set up Solace on our local machine. Navigate to the provided link [1] and use the following commands to pull a Docker image from Solace:
Windows / Linux Users
docker run -d -p 8080:8080 -p 55555:55555 -p 8008:8008 -p 1883:1883 -p 8000:8000 -p 5672:5672 -p 9000:9000 -p 2222:2222 --shm-size=2g --env username_admin_globalaccesslevel=admin --env username_admin_password=admin --name=solace solace/solace-pubsub-standard
Mac OS users
docker run -d -p 8080:8080 -p 55554:55555 -p 8008:8008 -p 1883:1883 -p 8000:8000 -p 5672:5672 -p 9000:9000 -p 2222:2222 --shm-size=2g --env username_admin_globalaccesslevel=admin --env username_admin_password=admin --name=solace solace/solace-pubsub-standard
Next, open your preferred browser and enter the following URL: http://localhost:8080. This will unveil the Solace dashboard. Access it by logging in with the credentials: user — admin, password — admin.
Now, let’s forge ahead by creating a new queue named “MyWso2Q.” Navigate to the queue section, click on the default box, and then select “Queues” from the left-side menu. To add a new queue, click on the +Queue option as illustrated below:
After you have created the Queue, you can see it in the Queue list below
Now we need to go to the JMS JNDI menu from the left side menu bar and go to the queue section
Let's create a JMS Queue by clicking the right top button “+ JMS Queue”. Give “MyWso2Q” as the JNDI name and select “MyWso2Q” as the physical name from the drop-down.
Congratulations! 🎉 We’ve successfully completed the setup process and created a new queue in Solace
Configuring WSO2 MI
Now, let’s proceed with configuring the WSO2 MI server. Navigate to the [MI_HOME]/conf directory and open the deployment.toml file.
Create a connection factory for the Solace transport sender by adding the following configuration to the deployment.toml file:
[[transport.jms.sender]]
name = "myQueueSender"
parameter.initial_naming_factory = "com.solacesystems.jndi.SolJNDIInitialContextFactory"
parameter.provider_url = "smf://admin:admin@localhost:55555"
parameter.connection_factory_name = "/jms/cf/default"
parameter.connection_factory_type = "queue"
parameter.cache_level = "producer"
Be sure to customize the Solace broker URL, client username, and client password with your specific credentials.
Following the configuration changes, it’s crucial to enhance your MI server by incorporating the following two Solace JARs into the [MI_HOME]/lib directory:
- sol-jcsmp-10.13.0.jar
- sol-jms-10.13.0.jar
Ensure these JAR files are correctly placed in the specified directory.
Now, let’s initiate the MI server and verify its ability to establish a connection with Solace. Navigate to the [MI_HOME]/bin directory, open the terminal, and execute the following command:
./micro-integrator.sh
Monitor the logs to confirm the successful establishment of the connection as below
Now let's create an API which will publish messages to our MyWso2Q queue in the Solace. You can use Integration Studio[2] to develop your API.
Below is my API synapse configuration
<?xml version="1.0" encoding="UTF-8"?>
<api context="/hellorestapi" name="HelloRestAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
<send>
<endpoint>
<address uri="jms:/MyWso2Q?transport.jms.ConnectionFactory=myQueueSender&transport.jms.DestinationType=queue">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
Now export the CAR app and place it in the [MI_HOME]/carbonapps directory
let’s invoke HelloRestAPI using the below CURL command
curl --location 'http://localhost:8290/hellorestapi' \
--header 'Content-Type: application/xml' \
--data '<name>Hello World!!</name>'
Now we will go to the Solace dashboard >> Queue >> MyWso2Q >> Message Queued section. You will see that the message that we sent from WSO2 MI is in the queue as below
Fantastic news! 🎉 The mission is accomplished as we’ve successfully published a message from WSO2 MI to the Solace JMS queue. Your integration journey just hit a major milestone. May this accomplishment contribute to seamless and efficient day-to-day integrations.
Happy coding, everyone! 🚀💻
[1].https://solace.com/products/event-broker/software/getting-started/
[2].https://ei.docs.wso2.com/en/latest/micro-integrator/develop/installing-WSO2-Integration-Studio/