Solution Patterns: Event Driven API Management

This solution pattern showcases an architecture approach for building event-driven API Management that expands your API Management strategy beyond RESTful APIs into event-driven architecture.

Rather than the synchronous request-response pattern of RESTful APIs,event-driven APIs facilitate asynchronous communication with pub-sub pattern between the API provider and the API consumers, allowing the API consumer to subscribe to an API product by providing a webhook endpoint to receive events in real time without the need for polling the API server.

The solution leverages Red Hat Application Foundations components to build a scalable webhook delivery system. This system pushes internal events from your event broker (Kafka) to your API consumers, allowing you to manage events as an API product by applying API management practices to an event-driven API product.

Contributors: Abdelhamid Soliman (Red Hat)


Solutions Patterns help you understand the art of the possible with Red Hat’s portfolio, and not intended to be used as is for production environments. You are welcome use any part of this solution pattern for your own workloads.

1. Use cases

Common use cases that can be address with this architecture are:

  • Manage, secure, monitor, monetize and control event-driven APIs using traditional API Management practices.

  • Enable to easily consume third-party and internal consumer applications through the friendly HTTP protocol by hiding the complexity of internal event broker (kafka)

  • Collaborate, document and self-service event-driven APIs through your developer portal.

  • Increase innovation as app developers (internal/external developers, partners) can build real-time reactive user interfaces and enable process automation based on internal business events in real time.

2. The story behind this solution pattern

This solution pattern extends Globex, a fictitious retail store that started the journey to event-driven architecture and has already adopted Kafka as an event broker and 3scale as an API management solution for REST APIs.

Globex wants to extend its eCommerce system to allow async real-time APIs and avoid the current pains of polling REST APIs (request-response communication pattern) for events.

polling

Globex would like to:

  • Manage an event-driven API product in the API Management for the event message that occurred in a Kafka topic. e.g. When the order has been created in the system a new record will be placed in the order-created topic to represent the new order.

  • To allow discoverability and self-service access to the order event with a schema based on the OpenAPI specification through the developer portal.

3. The Solution

Globex’s architecture team has decided to leverage the API Management solution for real-time event-driven asynchronous APIs by exposing internal events in the existing event broker (Kafka) to consumers through webhook callbacks.

A webhook is an HTTP request that sends data to the API Consumers through the registered endpoints, where no data is expected in the response. It is a one-way push of data to notify them of the event that has occurred. A webhook is usually an HTTP POST with a JSON payload that expects a 2xx response to acknowledge receipt of the payload.

webhook

In this pattern, you will learn how to design and build a reliable, secure and scalable webhook delivery system.