In this tutorial, we will demonstrate step by step guide to integrate Solace with MuleSoft using JMS Connector with simple real-time example.
What is Solace PubSub+?
As per Solace, PubSub+ is a platform that enables the design, discovery, streaming and full lifecycle management of events across distributed enterprises. It provides all of the tools necessary to support a modern event-driven architecture.
The main components of the platform are PubSub+ Event Brokers, PubSub+ Event Portal and PubSub+ Cloud Console.
Advantages of Event Driven Architecture
Below are the few Advantages of event-driven architecture.
- Flexibility
- Scalability
- Loose coupling
- Easy to scale
- Realtime identifications and many more.
Now let’s see how to integrate Solace PubSub+ with MuleSoft in real-time scenarios.
Integrate Solace with Mule
Follow below steps to integrate Solace with Mule using JMS Connector over Solace JMS API.
Step 1: Create Free Solace Trail Account
- Go to https://console.solace.cloud/login/new-account and create new free trail account.

- Up on successful signup, you will be redirected to Solace PubSub+ portal.

Step 2: Create Message Service
- Expand the sidebar and click on Cluster Manager to create the message service.

- Now Let’s spin up a new service. Currently there are new service types available.
- Enterprise: A highly available Service on dedicated infrastructure with customizable connections.
- Developer: A Service on dedicated infrastructure with 100 connections.
In this example, we will go with Developer service.
#1: Select the Service Type as Developer.

#2: Select the Cloud – where you want to host your service.

#3: Select the region.

In this case, will select US East (N.Virginia).

#4: Select the broker version, name your service and then click on Start Service.

Your service will start in few mins.

Now the service is up and running.

Step 3: Add Solace KeyStore in Mule
Next we will need to add the Solace Keystore file in our Mule project to authenticate Solace PubSub+ Cloud.
Follow below steps to obtain the .pem file.
#1: Open the newly added service i.e., vv-dev-mule.
#2: Now,
- Click on Connect
- Select Solace Messaging
- Select Solace JMS API

#3: Now copy the Maven dependency snippet and also download the TrustStore

#4: Open KeyStore file explorer, create new KeyStore and select JKS.

#5: Import the downloaded TrustStore(.pemfile) from Solace. To import, simply click CTRL+T and select the file to import.

#6: Save the file. You may need to enter KeyStore password to secure the file.

Step 4: Configure Message Service
Let’s configure the message service to connect Event broker using different authentication methods. In our case, we will use the default Basic Authentication.
#1: Click on message VPN and your will be redirected to the your message vpn (message service) dashboard.

Message VPN – Here you can check the summary, configuration such as TLS, REST and Stats.

Access Control – Where you can see and configure the Authentication and Access controls. You can configure the Client Authentications such as OAuth provider, ACL Profiles, Client usernames, etc.,
For more information about Solace PubSub+ configuration, read the official documentation.
Step 5: Configure Queues
Before get started, lets understand the concept of Queues and Topics.
Queues:
- Support only point-to-point communication.
- Messages can be consumed by only one single consumer.
Topics:
- Support one-to-many communication.
- Messages can be consumed by many consumers.
Now let’s create 2 sample queues.

Also associate topics to each queue. For example,
vv-emp-queue subscribed to vv-emp-topic.

vv-emp-error-queue subscribed to vv-emp-error-topic.

Step 6: Develop Sample Mule Application
Now let’s create a sample mule application with two different flows.
#1: Create sample mule project and add the solace dependency in the pom.xml as shown below,
<dependency>
<groupId>com.solacesystems</groupId>
<artifactId>sol-jms</artifactId>
<version>10.2.1</version>
</dependency>
Also make sure to add the JMS module to the project.

#2: Now configure the Global JMS configuration as follows,

JMS Provider properties

Flow#1:
Let’s develop a sample flow to publish message to the topic as shown below,

Deploy the mule application and post a message as showb below,

Switch back to the vv-dev-mule message vpn and open the vv-emp-queue. There you should see the message as shown below,

That’s simple.
You may get a doubt that, we published message to topic but how come its in the queue? Very simple, we have subscribed to the above topic in the previous section right?

Flow#2:
Let’s develop a flow to consume the above published message and insert the employee record to MySQL database and also in case of error, publish the message to error queue.

Note: The above flow is just for reference.
Configure On New Message as shown below,

Note: We have selected MANUL acknowledge mode as we will need to send Ack post processing of the message not immediacy after consuming the message.
As per our flow configuration, messages will be deleted from the queue only after success response from database.
Read : How to integrate MySQL with MuleSoft in Mule 4
Now deploy the mule application and publish a message to the topic (vv-emp-topic).
As soon as you publish the message to the topic, the subscriber flow triggered and consumed the message from the Queue.

And the employee record has been inserted to employee table.

That’s simple!
In the same way, whenever an error occurred in a flow, the original message will be published to error topic and you can reprocess the messages later.
Note: As we are using MANUL acknowledge mode, you may end up having same messages in both the queues (vv-emp-queue and vv-emp-error-queue).
Resources
- You can clone the sample project from Vanchiv GitHub.
References
- https://docs.solace.com/Solace-PubSub-Platform.htm
- https://solace.com/blog/queues-vs-topic-endpoints/
- https://vanchiv.com/how-to-connect-mysql-with-mulesoft-in-mule-4/
- https://solace.community/
Conclusion
We hope this tutorial helped you to integrate Solace with MuleSoft using JMS Connector. Solace also developed Solace Connector for MuleSoft, but its not yet certified and not available in Anypoint Exchange.
Please do share it with your friends and don’t forget to follow us on Facebook, Twitter and LinkedIn. Visit our MuleSoft Hub for more tutorials and updates.