[Proposal] Controller Spec - Message Broker as Subscribable APIs over Web-friendly Protocols #1884
Replies: 4 comments 1 reply
-
Beta Was this translation helpful? Give feedback.
-
|
I have a few questions/concerns.
|
Beta Was this translation helpful? Give feedback.
-
|
Hi @nuwand , Please find the spec below, alongwith descriptions that addresses the above questions: Spec{
"apiVersion": "gateway.api-platform.wso2.com/v1alpha1",
"kind": "WebBrokerApi",
"metadata": { "name": "<api-name>" },
"spec": {
"displayName": "<api-display-name>",
"version": "<api-version>",
"context": "<api-context>",
"receiver": {
"name": "<receiver-name>",
"type": "<receiver-type>",
"properties": { /* Properties of the receiver */ }
},
"brokerDriver": {
"name": "<brokerDriver-name>",
"type": "<brokerDriver-type>",
"properties": { /* Properties of the broker driver */ }
},
"policies": {
"on_connection_init": [
/* Policies applied to every initial connection */
],
"on_produce": [
/* Policies applied to every inbound message (web-friendly client to broker) */
],
"on_consume": [
/* Policies applied to every outbound message (broker to web-friendly client) */
]
},
"channels": {
"<channel-name>": {
"produceTo": { "topic": "<produce-messages-to-this-topic>" },
"consumeFrom": { "topic": "<consume-messages-to-this-topic>" },
"policies": {
"on_connection_init": [
/* channel-specific initial connection response policies */
],
"on_produce": [
/* channel-specific policies for inbound messages (web-friendly client to broker) */
],
"on_consume": [
/* channel-specific policies for outbound messages (broker to web-friendly client) */
]
}
}
},
"deploymentState": "deployed"
}
}
For an API which exposes a broker over a web-friendly protocol, there will be following events, on which we can apply policies:
Policies can be applied for the above events, across all channels ( Naming convention for all-channel policies and channel-specific policies follows the same convention of WebSub APIs. Topic MappingMessages that are sent via a particular channel from the web-friendly client, will be mapped and sent to the topic denoted by "channels": {
"<channel-name>": {
"produceTo": { "topic": "<produce-messages-to-this-topic>" },
"consumeFrom": { "topic": "<consume-messages-to-this-topic>" },
...
}
}An Example{
"apiVersion": "gateway.api-platform.wso2.com/v1alpha1",
"kind": "WebBrokerApi",
"metadata": {
"name": "stock-trading-v1.0"
},
"spec": {
"displayName": "Stock Trading WebBroker API",
"version": "v1.0",
"context": "/stock-trading/v1.0",
"receiver": {
"name": "websocket-receiver",
"type": "websocket"
},
"brokerDriver": {
"name": "kafka-driver",
"type": "kafka",
"properties": {
"bootstrapServers": [
"kafka-broker-1:9092",
"kafka-broker-2:9092"
]
}
},
"channels": {
"prices": {
"produceTo": {
"topic": "stock.prices"
},
"consumeFrom": {
"topic": "stock.prices"
},
"policies": {
"on_connection_init": [],
"on_produce": [],
"on_consume": []
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
|
Please find the revamped spec below, based on our latest discussion. Spec for
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Overview
The API Platform Event Gateway should support protocol mediation, where a message broker (such as Kafka, MQTT) is exposed as a subscribable API to clients over web-friendly protocols (such as WebSocket, SSE, WebSub). The broker is considered as a backend, and an external client consumes messages from, and/or produces messages to that broker, over web-friendly protocols.
So far, we support WebSub APIs, adhering to the WebSub Spec, where the Event Gateway functions as the WebSubHub, backed by a broker.
As the next step, we will be supporting exposing message brokers over web-friendly protocols like WebSocket and SSE, as subscribable APIs.
Spec (See the updated spec here)
We have come up with the following spec to represent such an API. This in an example which shows a WebSocket to Kafka API.
{ "apiVersion": "gateway.api-platform.wso2.com/v1alpha1", "kind": "WebBrokerApi", "metadata": { "name": "websocket-kafka-api-v1-0" }, "spec": { "displayName": "websocket-kafka-api", "version": "v1.0", "context": "/websocket-kafka", "receiver": { "name": "my-websocket-client", "type": "websocket", "properties": {} }, "brokerDriver": { "name": "my-kafka-broker", "type": "kafka", "properties": { "topic": "repo-events", "bootstrap.servers": "localhost:9092", "security.protocol": "PLAINTEXT" } }, "allChannelPolicies": { "on_connection_init": { "request": [ { "name": "api-key-auth", "version": "v1", "params": { "in": "header", "name": "X-API-Key" } } ], "response": [] }, "on_produce": [ { "name": "map-topics", "version": "v1", "params": { "extraction": { "source": "header", "key": "X-Client-Topic" }, "mappings": { "client-issues-topic": "kafka-repo-issues", "client-commits-topic": "kafka-repo-commits", "client-pr-topic": "kafka-repo-pull-requests" }, "defaultTopic": "kafka-repo-events" } } ], "on_consume": [] }, "deploymentState": "deployed" } }receiveris the Web-friendly protocol client (eg: WebSocket).brokerDriverpoints to the message broker (eg: Kafka).on_connection_initrefers to the initial connection (eg: handshake in WebSocket).on_produce- 'Produce' refers to sending a message from the web-friendly protocol client, to the broker.on_consume- 'Consume' refers to the web-friendly protocol client, consuming a message from the broker.Beta Was this translation helpful? Give feedback.
All reactions