Real-time Messaging through Solace PubSub+ Cloud Integration with MuleSoft

Written by Harini Krish

Lead Technical Content Writer

Our world is full of events; likewise, even the applications need to be event-driven. When a debit or credit card is swiped, an event is triggered with a set of other downstream events. For instance, your phone receives a real-time alert notifying you that your card was just swiped, your card balance is updated, etc.

Solace PubSub+ is a plug and play with MuleSoft’s Anypoint Platform and can be used to strengthen, extend, and event-enable the data movement layer.

Here, we will see how to integrate Solace PubSub+ Cloud with MuleSoft. Let us learn a little bit about Solace PubSub+ Cloud platform, its capabilities, how to set it up, and finally, how to integrate with the MuleSoft Anypoint Platform to amplify its capabilities.

What is Solace PubSub?

Solace PubSub is a comprehensive event streaming and management platform for enterprises. PubSub+ supports organizations to design, deploy and manage event-driven architectures with hybrid cloud, multi-cloud and IoT environments to be more integrated and event-driven.

The Image Below Describes the Features & Capabilities of Solace PubSub+ Cloud

How to Setup Solace PubSub+ Cloud account?

  1. Open to this link https://console.solace.cloud/ in a web browser and create Solace PubSub+ Cloud.
  2. Now Sign in to Solace PubSub+ Cloud account. You should be able to see Mesh Builder and Messaging Service options on the main screen.

How to Create a New Messaging Service in Solace PubSub+ Cloud?

  1. Click on Messaging Service after logging into your account.
  2. Click +(plus) card sign to create a new Messaging Service.
  3. Give details in required fields for Messaging Service.
  • a. Select service type (Free, Starter or Professional)
  • b. Select cloud (AWS, GCP, Microsoft Azure)
  • c. Select region
  • d. Service name
  1. Once the details are provided, click the Start Service button. After a while, there should be a new service up and running. See image below for an example.
  1. Now click on this service and explore these tabs Status, Connect, Manage, Configuration and Try Me!

Steps to Publish the Message to Topic using REST API

  1. Click on the Connect tab and see the details for REST API. This information will be used later to publish message to the Topic. Connection details should be similar to the image below.
  1. Now click on Manage tab and select Message VPN.
  1. Now explore options for Message VPN from the left sidebar.
  1. Click on Queues option and create a new Queue named testQueue.
  2. In settings for this Queue, let the options be as they are and click Apply button on the top left to save the details.
  1. Now Click on Subscriptions tab for testQueue queue and create a topic named testQueue/testTopic.
  1. Open any REST client like Postman or ARC and publish messages to this topic (The connection details mentioned in step 1 for REST API, is used here to publish messages).
  1. Now go to Queues tab in Solace Cloud and notice that messages sent to this topic (testQueue/testTopic) must be persisted in testQueue since there’s no consumer.

How to Consume Messages in MuleSoft using JMS

  1. Create a new MuleSoft project from Anypoint studio and give it any name as you like.
  2. Drag and Drop JMS Listener to the flow and configure it.
  3. For JMS Config, enter following details.

Note

  • configure sol-jms library for JMS Client in Required Libraries section.
  • Jndi provider url should have this format: smf::@:. This detail can be found in Connect tab from Message Service option as it was done for REST API above.
  1. Now test the connection which should succeed.
  2. For General section in JMS Listener,
  • Destination should be testQueue
  • Consumer Type should be Queue Consumer
  • Acknowledge Mode should be Immediate
  1. Add a Logger after JMS Listener to verify consumed messages.
  2. Now Run the application.
  3. Verify in mule logs that all messages in testQueue have been consumed and testQueue Queue is empty in Solace Cloud.

All these capabilities are available in a unified Cloud Console using a single sign-in, making it seamless for developers, architects, and other users to collaborate and work to drive the enterprise’s mission forward. Reach out to our Royal Cyber expert team.

Leave a Reply