Chamindu Udakara
7 min readMar 24, 2022

--

SOLACE Broker Integration With WSO2 API Manager

Welcome, all the WSO2 API Manager fans! We have great news about the latest API Manager release, WSO2 API Manager 4.1.0.

From the API Manager 4.1.0 onwards, WSO2 API Manager supports the integration with External 3rd party vendor-owned Gateways and Brokers. The integration with these external party brokers and gateways will expand the integration possibilities of the WSO2 API Manager users. With this feature, WSO2 API Manager can now be integrated with Solace PubSub+ event broker.

What is a Solace Broker?

Solace is an advanced event broker that efficiently streams events and information across cloud, on-premises, and IoT environments. It supports a wide range of message exchange patterns beyond publishing and subscribing, including request/reply, streaming, and replay, as well as different qualities of service, such as best effort and guaranteed delivery. It's available as an appliance, software, and a service. All options offer the same functionality and management experience.

Integration With Solace Broker

From API Manager 4.0.0, the WSO2 API Manager supports Async APIs. As an improvement for the API manager team expects to introduce a new feature of Solace integration with API manager in the latest release. When a user has the configurations for the Solace gateway environment, the user should easily integrate that environment with the API manager. And once you possess the Async API definition with topics, the Async API should be published into the solace event broker. It should be able to perform operations through the WSO2 API Manager.

Let's dig in…..

Steps to Integrate WSO2 API Manager with Solace.

  1. Visit the Solace PubHub+ portal and create a new account by providing the necessary information.
Solace broker registration portal

2. Once the registration is complete, extract the following information to integrate Solace broker with WSO2 API Manager.

  • The Username of the Account.
  • The password of the Account.
  • Developer name of the Account.
  • Developer organization name.

3. Then open <API-M_HOME>/repository/conf/deployment.toml file.

4. Add a new environment with the required additional properties, as illustrated below.

5. Once this is added, the Solace broker gateway will be available for Solace API deployments in the Publisher portal.

The single solace environment is integrated with the WSO2 API Manager.
Multiple solace environments are integrated with WSO2 API Manager.

“Now the Solace event broker is integrated with WSO2 API Manager and added as an external environment.”

Now let's create an API with Solace specification and Deploy it to Solace broker😁😁.

Solace API Creation and Deployment.

Users can use the Async API specification generated from Solace PubSub+ Hub to create the WSO2 API Manager APIs. The Solace API Specifications are slightly different from typical Async API specifications. Hence the user needs to use an Async API Specification generated from the Solace PubHub+ to create an API.

Step 1 — Import Solace Specification and Create a Solace API

  1. Add the required configuration to <API-M_HOME>/repository/conf/deployment.toml file to add the Solace broker gateway.
  2. Sign in to the Publisher.
    https://<hostname>:9443/publisher
    (For testing purposes, you can use https://localhost:9443/publisher and admin as the username and password.)
  3. Click CREATE API and then click Import AsyncAPI Definition.
Create Async API panel

4. The following two options to import the AsynAPI definition appears.

  • AsyncAPI URL — If you select this option, you need to provide a URL of a Solace API Specification.
  • AsyncAPI File — If you select this option, click Browse File to Upload and upload a file containing a Solace AsyncAPI definition.

5. Select how you will import the AsynAPI definition, and click Next.

If the Async API specification is a valid Solace Async API specification, the portal will display the “Identified as Solace Event Portal API” tag.

Identification of Solace Specification

6. Edit the Solace Async API information and click Create.

The AsynAPI definition of the Solace API will contain the specific API definition, with the supported protocols, such as HTTP, MQTT, AMQP, that the API topics have to use. You do not need to provide the protocol information separately.

For this example, let's design a Solace API using the following information.

Sample Solace API Creation Example

7. Now, the MaintainanceAPI API overview page will appear.

Solace API Overview in API Manager Publisher portal

Step 2 — Deploy to Solace Broker

For Solace APIs, the Deployments view will only list the Solace environments. But the environment configurations should be provided beforehand.

  1. Navigate to the Deployments under the Deploy section.
The single solace environment is integrated with the WSO2 API Manager.

2. Then select the Deployment environment and click Deploy.

3. Then, API revision will be created, and select the API revision and click Deploy.

4. Then Solace API will be deployed to the Solace Broker environment that user-provided and show the following view.

Solace API revisions deployments

Step 3- Publish API

  1. Next, publish the API.

Viola!!! NOw you have created, deployed and published Solace API via WSO2 API manager Publisher portal.

Now we have done the admin and creation parts. Let's work on consumption on Solace APIs via WSO2 API Manager….😎😇

Solace API Subscription.

You have to subscribe to a published Solace API before consuming them. The subscription process fulfils the authentication process and provides you with access tokens that you can use to invoke an API. The WSO2 API Manager will control the subscription flow.

When the application is attached with a Solace API Subscription, the solace broker will keep a copy of that application for the authentication and validation process of the tokens generated by the WSO2 API Manager.

The following are the two methods available in the Developer Portal to subscribe an API to an application.

  • Subscribe to an existing application
    (You can subscribe to a current API by selecting an existing application.)
  • Subscribe to an API using Key Generation Wizard
    (You can use the SUBSCRIPTION & KEY GENERATION WIZARD option to start the subscription process from scratch.)
Overview of Solace API in the Developer portal

Solace API Invocation.

Once the subscription is created, the Solace API overview and a new information page will be shown in the developer portal to support Solace API invocation.

Step 1 — Subscribe to Solace API

  1. Sign in to the WSO2 Developer Portal (https://<hostname>:9443/dev portal), select the Solace API, and Navigate to the Overview window.
  2. Subscribe to the API (e.g., MaintainanceAPI 1.0.0) using an application and an available throttling policy.
  3. Click Applications and then click on the application you used to subscribe to the API.

Step 2- Key Generation

  1. Click Production Keys and navigate to OAuth2 Tokens.
Key generation for Solace API subscribed application.

2. Scroll down and generate a production key or Sandbox key.

Generate keys for Applications.

3. Copy the generated Access Token.

Step 3 — Async Protocol and Topic selection

  1. Select the Solace API and click on the Solace Info section in the left menu bar. And it will render an information page like follows.
Solace API Topics available to consume

2. Then select the info page's Application, Environment, and Protocol dropdowns.

  • Application — Select the required Application of the subscribed Application of the Solace API.
  • Environment — Select the deployed Solace broker environment that needs to be used.
  • Protocol — Type of the transport protocol to invoke the Async topics with.

3. Once these things are appropriately selected, the topics supported for the selected Application, Environment, and protocol will be rendered.

4. Copy the endpoint URL of the selected protocol of the chosen environment.

Get the endpoint URL for the required protocol.

5. Then copy the topic that needs to be consumed. To copy the topic of need, click on the Copy icon in front of the topic.

Copy the Async topic to be consumed

6. Then, use this information to create a request on the desired protocol to invoke the topic and consume the topic.

That's all. Easy, isn't it? In this article, I have explained how to integrate with Solace broker with WSO2 API Manager 4.1.0, create and deploy a Solace API, and then extract all the required information to invoke Solace API topics. Now it's time for you to dive alone.

Thanks and Goodbye until the next time… 😁✌🏻✌️🤘🏻

References

https://github.com/wso2/product-apim/releases/tag/v4.1.0-m2

https://solace.com/products/event-broker/

https://apim.docs.wso2.com/en/latest/deploy-and-publish/publish-on-dev-portal/publish-an-api

https://apim.docs.wso2.com/en/latest/consume/manage-subscription/subscribe-to-an-api/#subscribe-to-an-existing-application

https://apim.docs.wso2.com/en/latest/consume/manage-subscription/subscribe-to-an-api/#subscribe-to-an-api-using-key-generation-wizard

--

--

Chamindu Udakara

Technical Lead, Full-stack Developer, Baseball player, Tech Enthusiast