Skip to content

Commit 83f90cc

Browse files
authored
Documentation for MQTT topics with path parameters (aklivity#311)
1 parent 6fae54f commit 83f90cc

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

src/reference/config/bindings/mqtt/.partials/routes.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,56 @@ An MQTT client identifier, allowing the usage of wildcards.
5252

5353
> `array` of `object`
5454

55-
Array of MQTT topic names for publish capability.
55+
Array of MQTT topic configs for publish capability.
5656

5757
#### publish[].topic
5858

5959
> `string`
6060

6161
The MQTT topic to match on that supports standard MQTT wildcards `/+/`, `/#`.
6262

63+
Also, supports embedded parameters (e.g., `{id}`) for dynamic topic matching.
64+
65+
#### publish[].params
66+
67+
> `object` as map of named `string`
68+
69+
Enforce validation of topic embedded parameters.
70+
71+
```yaml
72+
publish:
73+
- topic: device/{id}
74+
params:
75+
id: ${guarded['jwt'].identity}
76+
```
77+
6378
#### when[].subscribe
6479

6580
> `array` of `object`
6681

67-
Array of MQTT topic names for subscribe capability.
82+
Array of MQTT topic configs for subscribe capability.
6883

6984
#### subscribe[].topic
7085

7186
> `string`
7287

7388
The MQTT topic to match on that supports standard MQTT wildcards `/+/`, `/#`.
7489

90+
Also, supports embedded parameters (e.g., `{id}`) for dynamic topic matching.
91+
92+
#### subscribe[].params
93+
94+
> `object` as map of named `string`
95+
96+
Enforce validation of topic embedded parameters.
97+
98+
```yaml
99+
subscribe:
100+
- topic: device/{id}
101+
params:
102+
id: ${guarded['jwt'].identity}
103+
```
104+
75105
#### routes[].exit
76106

77107
> `string`

src/reference/config/bindings/mqtt/.partials/server.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111
- v5
1212
- v3.1.1
1313
routes:
14-
- when:
14+
- guarded:
15+
my_jwt_guard:
16+
- mqtt:stream
17+
when:
1518
- session:
1619
- client-id: "*"
1720
- publish:
18-
- topic: command/one
19-
- topic: command/two
21+
- topic: device/{id}/location
22+
params:
23+
id: ${guarded['my_jwt_guard'].identity}
24+
- topic: device/{id}/temperature
25+
params:
26+
id: ${guarded['my_jwt_guard'].identity}
2027
- subscribe:
2128
- topic: reply
2229
exit: mqtt_kafka_proxy

0 commit comments

Comments
 (0)