Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 7e287fb

Browse files
authored
Use inline catalog in open/asyncapi examples (#117)
1 parent d600f52 commit 7e287fb

File tree

13 files changed

+397
-356
lines changed

13 files changed

+397
-356
lines changed

mqtt.kafka.asyncapi.proxy/docker/compose/docker-compose.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ services:
1414
ZILLA_INCUBATOR_ENABLED: "true"
1515
volumes:
1616
- ../../zilla.yaml:/etc/zilla/zilla.yaml
17-
- ../../mqtt/asyncapi.yaml:/etc/zilla/mqtt/mqtt-asyncapi.yaml
18-
- ../../kafka/asyncapi.yaml:/etc/zilla/kafka/kafka-asyncapi.yaml
1917
command: start -v -e
2018

2119
networks:

mqtt.kafka.asyncapi.proxy/k8s/helm/setup.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ echo "Installing $ZILLA_CHART to $NAMESPACE with Kafka at $KAFKA_HOST:$KAFKA_POR
1414
helm upgrade --install zilla $ZILLA_CHART --namespace $NAMESPACE --create-namespace --wait \
1515
--values values.yaml \
1616
--set extraEnv[1].value="\"$KAFKA_HOST\"",extraEnv[2].value="\"$KAFKA_PORT\"" \
17-
--set-file zilla\\.yaml=../../zilla.yaml \
18-
--set-file configMaps.mqtt.data.mqtt-asyncapi\\.yaml=../../mqtt/asyncapi.yaml \
19-
--set-file configMaps.kafka.data.kafka-asyncapi\\.yaml=../../kafka/asyncapi.yaml
17+
--set-file zilla\\.yaml=../../zilla.yaml
2018

2119
# Create the mqtt topics in Kafka
2220
kubectl run kafka-init-pod --image=bitnami/kafka:3.2 --namespace $NAMESPACE --rm --restart=Never -i -t -- /bin/sh -c "

mqtt.kafka.asyncapi.proxy/kafka/asyncapi.yaml

Lines changed: 0 additions & 66 deletions
This file was deleted.

mqtt.kafka.asyncapi.proxy/mqtt/asyncapi.yaml

Lines changed: 0 additions & 76 deletions
This file was deleted.

mqtt.kafka.asyncapi.proxy/zilla.yaml

Lines changed: 139 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,151 @@
11
---
22
name: zilla-mqtt-kafka-broker
3+
catalogs:
4+
catalog0:
5+
type: inline
6+
options:
7+
subjects:
8+
mqtt:
9+
schema: |
10+
asyncapi: 3.0.0
11+
info:
12+
title: Zilla MQTT Proxy
13+
version: 1.0.0
14+
license:
15+
name: Aklivity Community License
16+
servers:
17+
plain:
18+
host: localhost:7183
19+
protocol: mqtt
20+
defaultContentType: application/json
21+
22+
channels:
23+
sensors:
24+
address: "sensors/{sensorId}"
25+
title: MQTT Topic to produce & consume topic.
26+
parameters:
27+
streetlightId:
28+
$ref: '#/components/parameters/sensorId'
29+
messages:
30+
item:
31+
$ref: '#/components/messages/item'
32+
33+
operations:
34+
sendEvents:
35+
action: send
36+
channel:
37+
$ref: '#/channels/sensors'
38+
39+
receiveEvents:
40+
action: receive
41+
channel:
42+
$ref: '#/channels/sensors'
43+
44+
components:
45+
parameters:
46+
sensorId:
47+
description: Sensor ID
48+
location: $message.header#/id
49+
messages:
50+
item:
51+
name: event
52+
title: An event
53+
contentType: application/json
54+
payload:
55+
type: object
56+
properties:
57+
item:
58+
$ref: "#/components/schemas/item"
59+
schemas:
60+
item:
61+
type: object
62+
properties:
63+
id:
64+
type: string
65+
status:
66+
type: string
67+
required:
68+
- id
69+
- status
70+
kafka:
71+
schema: |
72+
asyncapi: 3.0.0
73+
info:
74+
title: Zilla Kafka Proxy
75+
version: 1.0.0
76+
license:
77+
name: Aklivity Community License
78+
servers:
79+
plain:
80+
host: host.docker.internal:9092
81+
protocol: kafka
82+
83+
operations:
84+
onSensorData:
85+
action: receive
86+
channel:
87+
$ref: '#/channels/sensorData'
88+
toSensorData:
89+
action: send
90+
channel:
91+
$ref: '#/channels/sensorData'
92+
93+
channels:
94+
sensorData:
95+
description: This channel contains a message for sensors.
96+
address: sensors
97+
messages:
98+
sensorData:
99+
$ref: '#/components/messages/sensorData'
100+
mqttSessions:
101+
description: This channel contains MQTT sessions.
102+
address: mqtt-sessions
103+
mqttMessages:
104+
description: This channel contains MQTT messages.
105+
address: mqtt-messages
106+
mqttRetained:
107+
description: This channel contains MQTT retained messages.
108+
address: mqtt-retained
109+
110+
components:
111+
messages:
112+
sensorData:
113+
payload:
114+
type: object
115+
properties:
116+
sensorId:
117+
type: integer
118+
description: This property describes the id of the sensor
119+
message:
120+
type: string
121+
description: This property describes message of the sensor
3122
bindings:
4123
asyncapi_mqtt0:
5124
type: asyncapi
6125
kind: server
7126
options:
8127
specs:
9-
mqtt_api: mqtt/mqtt-asyncapi.yaml
128+
mqtt_api:
129+
catalog:
130+
catalog0:
131+
subject: mqtt
132+
version: latest
10133
exit: asyncapi_proxy0
11134
asyncapi_proxy0:
12135
type: asyncapi
13136
kind: proxy
14137
options:
15138
specs:
16-
mqtt_api: mqtt/mqtt-asyncapi.yaml
17-
kafka_api: kafka/kafka-asyncapi.yaml
139+
mqtt_api:
140+
catalog:
141+
catalog0:
142+
subject: mqtt
143+
version: latest
144+
kafka_api:
145+
catalog:
146+
catalog0:
147+
subject: kafka
148+
version: latest
18149
mqtt-kafka:
19150
channels:
20151
sessions: mqttSessions
@@ -40,7 +171,11 @@ bindings:
40171
kind: client
41172
options:
42173
specs:
43-
kafka_api: kafka/kafka-asyncapi.yaml
174+
kafka_api:
175+
catalog:
176+
catalog0:
177+
subject: kafka
178+
version: latest
44179
tcp:
45180
host: ${{env.KAFKA_HOST}}
46181
port: ${{env.KAFKA_PORT}}

mqtt.proxy.asyncapi/README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
Listens on mqtt port `7183` and will forward mqtt publish messages and proxies subscribes to mosquitto MQTT broker listening on `1883` for topic `smartylighting/streetlights/1/0/event/+/lighting/measured`.
44

5-
Note that the `zilla.yaml` config used by the proxy was generated based on `asyncapi.yaml`.
6-
7-
For example:
8-
9-
```bash
10-
cat asyncapi.yaml | \
11-
docker run --rm -e ZILLA_INCUBATOR_ENABLED='true' -i ghcr.io/aklivity/zilla \
12-
generate --template asyncapi.mqtt.proxy --input /dev/stdin --output /dev/stdout | \
13-
tee zilla.yaml
14-
```
155

166
### Requirements
177

0 commit comments

Comments
 (0)