Perhaps the biggest barrier to adopting an Event-Driven architecture is modernizing legacy applications. Despite the value of this transformation, legacy applications are hard to maintain and brittle—and refactoring them is less than ideal. The Solace Event Broker takes a lot of the complexity out of building/maintaining queues and setting up the routing, however, messages must contain a Topic to publish them to the correct queue. This is where Axway can help.
This post is part of a five-part series covering the following topics:
- Getting Started with Solace’s REST Client
- Enhancing Legacy Messages – Axway API Gateway and Solace REST Client
- Enhancing Legacy Messages – Axway API Gateway and Solace JMS Client
- Integrating 3rd Party Cloud Apps – Axway Application Integration and Solace
- Evolving Request/Response APIs to Events – Axway Streams and Solace
Axway API Gateway and Solace REST Client
In this, the second in the series of blog posts detailing Axway’s integration with Solace PubSub+ Event Broker, I explore taking a sample message and enhancing it in the Axway API Gateway with the appropriate headers and topic to allow the Solace REST Client to route it to the proper queue.
For this sample, I use the message body as a source to extract the Topic, but it could also come from a Header, a query parameter, or even additional policy logic in the API Gateway that mapped some message context (IP, Cert Issuer, etc.) to a Topic list.
To do this, we will use Postman as a client to POST a JSON message to the API Gateway. The API Gateway will parse the message to extract a key-value pair that can be used as the Topic. The API Gateway will then enhance the message with Headers as needed to integrate with the Solace Event Broker, then dynamically publish the message to the appropriate Solace Event queue using their REST Client.
Prerequisite Knowledge
- A basic understanding of creating policies in the API Gateway Policy Studio.
- A basic understanding of using Postman or a similar client.
Configure Solace to Listen for Enhanced Message
- Log into Solace: https://console.solace.cloud/
- Navigate to “Messaging Services” on the left-hand menu bar, and select your instance.
- Go to “Connect” on the top menu and expand the REST Client. You will need to capture your REST Host, Username and Password.
- Select a Topic name you will use for testing. Capture this Topic Namefor later use.
- Navigate to “Try Me” on the top menu bar. Select “Connect” on the Subscriber. Add a Topic which you want to monitor. Remember the Greater Than (>) sign can be used to capture everything. For this demo, I wanted to limit the Topics being monitored to ensure everything worked as intended. I chose “test/axway” as my Topic and selected the “Subscribe” button.
You should now be Subscribed to a queue, which will display messages in real-time as they are delivered to the Solace Event Broker. You should have captured your REST Host, Username, Password, and Topic Name for use in the next section.
Configure the API Gateway Policy
- Construct a sample message that will be used later to POST a request to the API Gateway from the Postman client. For my testing, I used the following JSON message.Sample JSON Message
{ “content”: “body”, “topic”: “test/axway” } |
- Open up Policy Studio and create a new policy.
- Drag and drop a “JSON Path” filter. We will use this to extract the topic from our sample message. Configure it to extract the appropriate value from the message. For my sample, I use the JSON Path “$.topic” and store it to the variable “topic”. This will dynamically parse any inbound message to this policy with that JSON path and assign that value to the topic variable. In my sample message, this is “text/axway”, which also corresponds to the Topic I subscribed to in the Solace console.
- In the Solace REST Client Library “Get Started” dialog, it provides a sample Curl command with an added “Solace-delivery-mode” Header. Gather this information. Drag and drop an Add HTTP Header filter to the Policy Studio canvas and configure it to add this header.
- Drag a “Connect to URL” filter into the Policy Studio canvas. For your URL you will need your “Solace REST Host” you captured earlier in the Solace console. Add a trailing forward-slash (‘/’) and then add your topic variable to complete dynamically URI and route to the appropriate Solace queue.
- Your final policy should look something like this, depending on how you aliased your Filters:
- Add a relative path to the policy and deploy it to your API Gateway instance.
At this point, you should have a basic APIGW policy that can extract a topic from an inbound message and dynamically route it to the appropriate Solace Topic queue. Instead of extracting it from the message, you could get it from a query parameter, HTTP Header, or even look at the message context (e.g., app name, organization, API endpoint, etc.) and maintain a topic mapping list to use. This is just a basic example of one way this could work.
Test the policy with Postman
- Open Postman and create a new request. Set it to POST and add your APIGW URL with relative path information for routing.
- Navigate to the Authorization tab. Choose “Basic Auth” as the type and fill out the Username/Password fields with the values captured earlier in the Solace console. Note: You could also manage the credentials within the Axway API Gateway.
- Navigate to the Body tab. Add your sample JSON message and change the content-type to JSON.
- Click the Send button to POST your message to the API Gateway, which should enhance the message for integration with the Solace Event Queue.
- Navigate back to the Solace Console “Try Me!” tab. Your message should be displayed here in the Subscribed Topic queue:
Conclusion
This post showed how we can transform and enhance a message to integrate with the Solace Event Broker REST Client. A similar policy could be used as a Routing or Response policy in Axway API Manager to enhance easily an existing API to work with the Solace Event Broker. This process could also be adapted to Axway AMPLIFY Streams or API Builder to do similar integrations with Solace.
In my next post, I will explore using the Axway API Gateway to connect with Solace via JMS.
Learn how to Get Started with Solace’s REST Client.