Benefits and limitations of Async API in MuleSoft Anypoint Platform
On October 14, 2021, MuleSoft announced support for the Async API (aka event-driven API) in the Anypoint Platform. Currently, the platform allows us to create or import an Async API specification in API Designer and then edit documents and publish them in Anypoint Exchange. The Async API is based on an open-source, industry-standard language that describes messaging interfaces.
Event-Driven architectures
Many architects, developers, and product managers have used REST APIs and are familiar with the synchronous communication paradigm. One makes a request and waits for the response.
However, there are certain situations where one doesn’t need a response from the server, just a confirmation that the request was received. This is known as “fire and forget”.
An example of this is:
Payment confirmation
Along with the event, one may send additional information like the transaction ID, Status, Transaction Timestamp, etc.
This additional information is referred to as the message payload or event payload.
Core concepts
EDAs are broker-centric, as seen in the diagram above.
Message broker
A message broker is a piece of infrastructure that receives and delivers messages to those who have subscribed to them. They have the capability to store messages until they are delivered, which makes them resilient. Examples of brokers are Apache Kafka, Solace, ActiveMQ, etc.
Publisher and subscriber
The publisher is responsible for sending messages to the broker.
The subscriber is responsible for connecting to a broker, registering its interest in certain types of messages, and consuming those messages by allowing the broker to deliver them.
Messages
A message is a piece of information that the publisher sends to the broker and that all registered subscribers receive.
Async API support in Anypoint platform
We have event-driven APIs using queues, topics, sockets, etc., but we don’t have a meaningful way to publish them. Fortunately, MuleSoft is evolving, adding support for the Async API in Design Centre and Anypoint Exchange.
Design centre: One can create Async API specifications in API Designer or import them from Exchange and edit the specification as per need.
Anypoint Exchange: One can document and publish Async APIs in Anypoint Exchange for consumers to discover them.
Advantages of Async API
- It has similarities with Open API and RAML specification
- Both human and machine-readable formats.
- Not dependent on protocols like MQTT, AMQP, web socket, etc.
Limitations of Async APIs
- Only Design Centre and Anypoint Exchange supported Async APIs at the time of writing his article.
- The API Manager cannot manage async APIs. So, they are called non-managed instances in Anypoint Exchange.
- Importing an Async API specification in Anypoint Studio and Flow designer throws an error as these two components do not support Async API