In this codelab, I will be showing you how to use and configure the Solace connector on MuleSoft Anypoint Platform to send or receive events.
The MuleSoft Anypoint Platform in an integration platform and acts as a complete solution for API-led connectivity. You can learn more about MuleSoft Anypoint here. Alternatively you can checkout the ultimate MuleSoft developer quick start guide
So put your seatbelt on and tag along in the following steps!
To run this codelab all you need
Access to a Solace messaging service, Solace PubSub+, can be achieved in anyone of the three flavours
If you already have a Solace PubSub+ Cloud account, you can skip this step
This tutorial will walk you through setting up a Solace Cloud service instance. If you are interested in setting up a local broker running on Docker or a virtual machine check out the PubSub+ Event Broker: Software documentation
Navigate to the Create a New Account page and fill out the required information. No credit card required!
After you create your Solace Cloud account and sign in to the Solace Cloud Console, you'll be routed to the event mesh page.
Click on ‘Cluster Manager' and all the messaging services associated with your account will show up if you have any already created. To create a new service, click either button as depicted in the image below:
Fill out all the details for your messaging service, and then click "Create" at the bottom of the page.
Your service should be ready to use in a couple seconds! 🌪
If you already have a MuleSoft Anypoint account and Anypoint Studio, you can skip this step.
<dependency> <groupId>com.solace.connector</groupId> <artifactId>solace-mulesoft-connector</artifactId> <version>0.3.3-SNAPSHOT</version> <classifier>mule-plugin</classifier> </dependency>
<repositories> <!-- keep all the mulesoft repositories that are configured here ---> <repository> <id>myMavenRepo.read</id> <url>https://mymavenrepo.com/repo/27AIdW4GdyXFzutegEs5/</url> </repository> </repositories>
mvn installwhich installs the solace connector
Now that the connector is installed, go ahead and navigate to
src/main/mule and double click on the xml file. When you do so, you will see an empty Message Flow canvas
Observe in the Main Palette on the right hand side the Solace Connector with all the different operations that you can use
Let's go ahead and create a basic flow that publishes events to a predefined topic on the previously created solace broker.
Addicon to add a new connection configuration
Now that you have a publisher object configured, let's test it out! In this step, we will configure a scheduler that will publish messages every second on a predefined topic
Schedulerunder the main palette catalogue on the left hand side of the IDE
Deliver Modemake sure its set to
Direct. The Destination name field is the topic; populate it with this topic
solace/mule/flowand add whatever you want in the Message Body
Before executing the flow, let's setup a subscriber on the broker to observe the messages flowing. To do so:
Connectand add a topic subscription
And that's it! You can check out more information on solace-iot-team/solace-mule-connector github repo to see other functionalities with the broker
Now that you have created a publisher flow and tested it out, let's go ahead and create a
TopicListener object that will connect to the broker and subscribe to the topic we sent. To do so:
TopicListenerobject into the canvas
Loggerfrom the pallette menu and drag it to the TopicListner flow
%dw 2.0 output application/java --- payload
✅ We were able to show how to create a new Solace Cloud Account
✅ Install Anypoint Studio
✅ Install the Solace Connector
✅ Configure a publish object
✅ Use the Solace Cloud TryMe tab to test out our connection and configuration
Thanks for participating in this codelab! Let us know what you thought in the Solace Community Forum! If you found any issues along the way we'd appreciate it if you'd raise them by clicking the Report a mistake button at the bottom left of this codelab.