Event-driven use case – publish subscribe

Event-Driven API Management is the combination of AMPLIFY™ API Management and next-gen Axway Streams with some configuration for seamless integration.

We already presented how to generate an Event-driven API from an API in Catalog with the “Change Data Capture” use case.

Event-driven use case – publish subscribe

But we are not done! In this blog, let see the publish/subscribe pattern. This is a very popular and well-known pattern.

It’s the main interaction used with messaging systems or Enterprise Service Bus. But how do you do it with APIs?

Let see Event-Driven API Management in action!

Use case

As the name stands, the publish/subscribe pattern has two parts:

  • A way to subscribe to a channel.
  • A way to publish data to all channel subscribers.

Now let’s replace “a way” with “an API.” And what is this channel? This is a next-gen Axway Streams topic. Publish/subscribe is a pattern provided by next-gen Axway Streams.

To deliver publish/subscribe with Event-driven API Management, there are three steps:

  1. Generate a new channel.
  2. Subscribe to the channel.
  3. Publish content.

Generate a new channel

Event-driven APIs can be generated from an API, directly in the API Manager catalog, as shown with Petstore. But there is no existing API here, we want to create a fresh new channel.

So, let’s use the Streams admin API! It can be used with API Portal Try-It, providing a user interface. Let show another solution: use of the well-known REST client curl.

Here is a curl example to create a topic:

curl -k -X POST -d ‘@create_topic.json’  -H “Content-Type: application/json” -H “KeyId: XXX” https://myhost:9001/api/v1/topics

As expected, data is sent as a POST to create a topic. Data is in file create_topic.json and here is its content:

Note our topic name is here publishapi. A topic has two parts:

  • Publisher, the way Streams acquires data. “http-post” means to create a new endpoint to receive data.
  • Subscribers, the way data is exposed by Streams. Only Webhook was defined on this topic.

The Event-Driven API Management added value is to register automatically APIs in API Manager. The purpose of the “edam” structure is to provide some control over API registration, like publish or grant.

In this case, two API entries are added, each corresponding to a publish/subscribe part:

  • publishapi_async: subscribe to the channel
  • publishapi_post: publish to the channel

Subscribe to the channel

publishapi_async is the Webhook subscription API. It has three methods to manage the subscription:

  1. Create
  2. Read
  3. Publish content

This is an API, like any other for API Manager. It can be edited, published, access granted, or requiring applications.

Like for any API, the best way of consuming it is with the API Portal.

An App developer can subscribe to the topic by creating a subscription. Try-It can be used, or any REST client.

Publish content

It is important to note that subscription and publishing APIs can be managed independently.

Subscription API is supposed to be opened to many. Publishing the API should have more restricted access or at least more control.

publishapi_post is simple to use. Post any data to it, and every subscriber receives it. API documentation can be accessed through the API Portal.

And an app with the right credentials would use it to publish data to many subscribers!

Let’s summarize

Publish/subscribe is a very popular pattern, but not common with an API Management solution.

Streams are capable to generate this interaction pattern, with publish and subscribe APIs. API entries can be registered automatically in API Management.

Just an API Call and you generate a channel to publish/subscribe!

Read how Axway unveiled its new Event-driven solution to stream APIs to your API strategy.

 

 

 

 

 

 

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here