Blog

Solace - MuleSoft Integration

Vikas PuriWritten by Vikas Puri

Here we are going to explore what Solace PubSub+ is, what it can do and how Solace MuleSoft Integration can be easily achieved.

Introduction to Solace:

Solace PubSub+ message brokers efficiently move information between all kinds of applications, users and devices, anywhere in the world, over all kinds of networks. Solace makes its state-of-the-art PubSub+ messaging middleware technology available in three ways:

  • Solace PubSub+ is a powerful message broker that runs on any computer in a virtual machine or a container.
  • SolacePubSub+ Cloud is a managed messaging as a service (MaaS) offering that lets developers easily tap into the power of Solace PubSub+ without installing, maintaining or upgrading messaging software.
  • Solace PubSub+ appliances route messages entirely in hardware for unparalleled capacity, performance and robustness, with the low TCO of a turnkey appliance.

Solace - MuleSoft Integration

Solace PubSub+ message brokers—set up as any combination of software, hardware or cloud—give you an enterprise-grade digital backbone because they support the key features listed below:

  • Support for all of the most popular cloud environments, public and private, IaaS and Paas, which combined with support for legacy non-cloud environments offers the only unified solution for hybrid cloud data movement.
  • Support for many different transport and protocols; making Solace PubSub+ message brokers ideal data distribution platforms to connect to any application.
  • Easy Integration with 3rd party products.
  • Enterprise grade security to ensure that your infrastructure and information are protected at all times.
  • High Reliability, including slow consumer control, fault tolerance, high availability and disaster recovery.
  • High Performance in terms of message throughput, data transfer rates and latency.

Now we have an idea about Solace, let us dive into the integration of Solace and MuleSoft.

Steps to Integrate Solace and MuleSoft:

  1. Navigate to https://console.solace.cloud/login link, and click on Sign Up to create an account in solace, where we will configure topics/queues.

Solace - MuleSoft Integration

  1. After clicking on Sign Up, the next screen will appear where you need to fill in all details and agree on the terms and conditions, and then click Sign Up which will create your account in Solace. This account is a trial account for 60 days.

  2. After successfully Sign-Up, the following screen will appear where you need to click on the “Cluster Manager“:

Solace - MuleSoft Integration

  1. After that, you need to create a new service, which you can do by clicking on the “+“ icon.

Solace - MuleSoft Integration

  1. For Service creation there are many things we need to select, the very first one is Service Type for that we have two options “Enterprise“ or “Developer“, as our account is trial, so we cannot leverage all the features. Hence, we need to select Developer in Service Type.

Solace - MuleSoft Integration

  1. The second option is we need to “Select Cloud” where we need to deploy the service, we have four options over here: Amazon Web Services, Google Cloud, Microsoft Azure, and Private Cloud. We are choosing “Amazon Web Services“ as the cloud to deploy our service.

  2. Then in the 3rd step, all the regions represented by green dots will appear where the Selected Cloud is having. You can select any of the regions by clicking on Green Dot.

  3. Next, you can give the name of your service. Below the name of the service, there is “Show Advanced Connection options“

Solace - MuleSoft Integration

  1. Click on the drop-down button corresponding to “Solace Messaging“ as below:

Solace - MuleSoft Integration

  1. After that, enable all the ports for “Solace Messaging“ by checking the check box:

Solace - MuleSoft Integration

  1. In the same way, Enable all the ports for Solace Web Messaging, AMQP, MQTT, and REST by checking the check box.

  2. After that click on the “Start Service“ button, it may take some time while starting service. Once the service got started following screen will appear:

Solace - MuleSoft Integration

  1. Click on the “Try Me!” tab as shown below:

Solace - MuleSoft Integration

  1. There you can see the Publisher and Subscriber section where you need to give the Topic name, here we replaced “try-me“ with “testTopic“, also the same we did in the Subscriber part. After this you need to make the connection of Publisher and Subscriber, please follow the exact sequence as mentioned below, so that we can see testTopic is published and connected, as well as we have subscribed to testTopic on the right with proper connection:

Solace - MuleSoft Integration

  1. Click on the “Connect“ tab as shown below, which just expands the “REST“ part, and note down the username, password, and REST host which we will use while configuring the HTTP request component during implementation.

Solace - MuleSoft Integration

  1. Expand solace message, note Username, Password, Message VPN, and SMF Host which will be used to configure the Listener.

Solace - MuleSoft Integration

  1. Now we are done with the Solace part, let us go for its integration on MuleSoft. Create a new Mule Project in AnyPoint Studio. Let us first focus on publishing to Topic part first, for this you need to create the below flow which will use HTTP Listener and HTTP Request component:

Solace - MuleSoft Integration

  1. Click on the Listener component, after you need to click on the “+“ symbol to create a new configuration:

Solace - MuleSoft Integration

After clicking on. “+“ symbol, below screen, will appear where you need to give configuration name, host and port, I have given below names then click on “Ok“:

Solace - MuleSoft Integration

  1. Then you need to provide a path, here I provided “/test“ as a path as shown below:

Solace - MuleSoft Integration

  1. Now let us configure the “HTTP Request“ component, click on the HTTP Request component below screen will appear just click “+“ corresponding to the configuration:

Solace - MuleSoft Integration

  1. After clicking on “+“ corresponding to Configuration, the below screen will appear:

Solace - MuleSoft Integration

  1. In Host and Port, fill with the values which we got from step 15. Something similar as below:

Solace - MuleSoft Integration

  1. Scroll down the Configuration you will find Authentication from there, you choose Basic Authentication:

Solace - MuleSoft Integration

  1. In the Username and Password, you can fill the user name and password which we get in Step 15, and then Click Ok.

Solace - MuleSoft Integration

  1. After the configuration is final, then we need to fill the following details in Request, in request method choose “POST“, and in the Path, we need to select what topic name we have given, so here in Path I mentioned “/testTopic“.

Solace - MuleSoft Integration

  1. Now we are done with publisher flow, now let us create the Subscriber flow. In Anypoint Studio:

Here we have uses the “On New Message“ component of JMS and logger to log the payload.

Solace - MuleSoft Integration

  1. Click on the logger, and log the payload as below:

Solace - MuleSoft Integration

  1. Now click the “On New Message“ component, in the Destination “testTopic“ as this is the name of Topic, and in the "Consumer type" choose “Topic consumer“ and in the "Number of Consumer" fill “1“.

Solace - MuleSoft Integration

  1. After that click on the “+“ icon corresponding to the configuration:

Solace - MuleSoft Integration

  1. After clicking on “+“ icon, following screen will appear:

Solace - MuleSoft Integration

  1. Now in the Connection field, choose “Generic Connection“:

Solace - MuleSoft Integration

  1. Click the “Configure“ button corresponding to “JMS Client“, then click on “Add Maven dependency“.

Solace - MuleSoft Integration

  1. Now in the Search Maven Central, search for “sol-jms“ as shown below, then select sol-jms:10.10.0 and click Finish:

Solace - MuleSoft Integration

  1. Now in Connection Factory, choose Edit Inline:

Solace - MuleSoft Integration

  1. In the “Connection Factory jndi name”, write “/jms/cf/default“:

Solace - MuleSoft Integration

  1. Now check the “Name resolver builder“, and fill the following details

Jndi intial context factory: com.solacesystems.jndi.SolJNDIInitialContextFactory

Jndi provider url: smf://username:password@smfurl

Now you can replace url username, password and smfurl with the details we got in Step 16.

eg: smf://solace-cloud-client:1or1gh58a8a6q0aul2h55r@mr1js1tiv0ygfj.messaging.solace.cloud:55555:

Solace - MuleSoft Integration

  1. Select “Edit Inline“ in the Provider Properties:

Solace - MuleSoft Integration

  1. Then add key and value in key write java.naming.security.principal and in its value write username@vpn where you can replace the value of username and message VPN in Step 16.

Solace - MuleSoft Integration

  1. Now in connection, fill the username and password which we got from Step 16, then click Ok.

Solace - MuleSoft Integration

  1. Now you are done with Integration, start the mule application and hit the endpoint with some message :

Solace - MuleSoft Integration

  1. Like we have a message as “Vikas“ in the body, so go to the solace console there you can see your published message:

Solace - MuleSoft Integration

  1. As we have also subscribed to a topic in our application, so the same message you can see in the logs of the mule application:

Solace - MuleSoft Integration

Conclusion

We hope that this walkthrough has been useful for you and that you now know how to best leverage the features of Solace through MuleSoft Integration.

References