How to Integrate Solace with MuleSoft using JMS API

How to Integrate Solace with MuleSoft using JMS API

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.

  1. Flexibility
  2. Scalability
  3. Loose coupling
  4. Easy to scale
  5. 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

create new solace account
  • Up on successful signup, you will be redirected to Solace PubSub+ portal.
solace portal

Step 2: Create Message Service

  • Expand the sidebar and click on Cluster Manager to create the message service.
cluster manager
  • Now Let’s spin up a new service. Currently there are new service types available.
    1. Enterprise: A highly available Service on dedicated infrastructure with customizable connections.
    2. 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.

solace service type

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

select solace cloud

#3: Select the region.

select the region

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

select solace region

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

name the service

Your service will start in few mins.

start event broker

Now the service is up and running.

solace service

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
solace jms messaging

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

solce jms dependency

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

create new keystore

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

import truststore

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

add jks 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.

manage message vpn

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

message vpn summary

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:

  1. Support only point-to-point communication.
  2. Messages can be consumed by only one single consumer.

Topics:

  1. Support one-to-many communication.
  2. Messages can be consumed by many consumers.

Now let’s create 2 sample queues.

sample queues

Also associate topics to each queue. For example,

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

topic subscription

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

error topic subscribe

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.

solace dependencies

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

solace jms configuration

JMS Provider properties

solace jms config

Flow#1:

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

publish operation config

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

sample postman req

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

message in queue

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?

topic subscription

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.

subscribe messages

Note: The above flow is just for reference.

Configure On New Message as shown below,

on new message config

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.

integrate solace pubsub+ with mule

And the employee record has been inserted to employee table.

employee table sample data

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

References

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 FacebookTwitter and LinkedIn. Visit our MuleSoft Hub for more tutorials and updates.

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.

  1. Flexibility
  2. Scalability
  3. Loose coupling
  4. Easy to scale
  5. 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

create new solace account
  • Up on successful signup, you will be redirected to Solace PubSub+ portal.
solace portal

Step 2: Create Message Service

  • Expand the sidebar and click on Cluster Manager to create the message service.
cluster manager
  • Now Let’s spin up a new service. Currently there are new service types available.
    1. Enterprise: A highly available Service on dedicated infrastructure with customizable connections.
    2. 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.

solace service type

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

select solace cloud

#3: Select the region.

select the region

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

select solace region

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

name the service

Your service will start in few mins.

start event broker

Now the service is up and running.

solace service

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
solace jms messaging

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

solce jms dependency

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

create new keystore

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

import truststore

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

add jks 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.

manage message vpn

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

message vpn summary

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:

  1. Support only point-to-point communication.
  2. Messages can be consumed by only one single consumer.

Topics:

  1. Support one-to-many communication.
  2. Messages can be consumed by many consumers.

Now let’s create 2 sample queues.

sample queues

Also associate topics to each queue. For example,

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

topic subscription

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

error topic subscribe

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.

solace dependencies

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

solace jms configuration

JMS Provider properties

solace jms config

Flow#1:

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

publish operation config

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

sample postman req

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

message in queue

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?

topic subscription

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.

subscribe messages

Note: The above flow is just for reference.

Configure On New Message as shown below,

on new message config

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.

integrate solace pubsub+ with mule

And the employee record has been inserted to employee table.

employee table sample data

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

References

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 FacebookTwitter and LinkedIn. Visit our MuleSoft Hub for more tutorials and updates.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related Articles

How to Create Multiple Folders at Once in Windows 10

Creating folders and subfolders manually is time consuming tasks...

How to Open Port on AWS EC2 Instance

In this tutorial, we will demonstrate step by step...

AWS Tutorial for Beginners to Experts [Step By Step Guides]

Welcome to AWS tutorial for beginners to experts series....

LEAVE A REPLY

Please enter your comment!
Please enter your name here