Skip to content

Commit

Permalink
Update mqtt proxy to broker (#876)
Browse files Browse the repository at this point in the history
* make mqttproxy a broker

* add more test and optim code

* udpate mqtt test

* optim code for mqttproxy

* update broker to eliminite possibility of concurrently run connectWatcher

* mqttproxy: optim store process, solve client connect to multi easegress instance conflict, optim resend time interval, and other updates based on comments

* refactor send msg part in broker mode

* update test

* update test

* optim mqtt client process publish

* optim code for processBrokerModePublish

* update doc of mqtt proxy

* update broker.go
  • Loading branch information
suchen-sci committed Dec 22, 2022
1 parent f99cd41 commit cd42976
Show file tree
Hide file tree
Showing 15 changed files with 1,431 additions and 288 deletions.
15 changes: 15 additions & 0 deletions doc/cookbook/mqtt-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- As `Pipeline` is protocol independent, it can use MQTT filters to do things like user authentication or topic mapping (map MQTT multi-level topic into single topic and key-value headers).
- We also support MQTT clients to `subscribe` topics (wildcard is supported) and send messages back to the MQTT clients through the HTTP endpoint.

By default:
```
publish msg publish pipeline
MQTT client ------------> Easegress MQTTProxy ----------------> Backend like Kafka
Expand All @@ -36,6 +37,18 @@ all msg send back to MQTT clients come from HTTP endpoint.
```
- We assume that IoT devices (use MQTT client) report their status to the backend (through tools like Kafka), and backend process these messages and send instructions back to IoT devices.

Using `brokerMode`:
```
publish msg publish pipeline
MQTT client ------------> Easegress MQTTProxy ----------------> Backend like Kafka
|
| also send msg to subscribers
|
subscribe msg send msg through http endpoint
MQTT client <------------ Easegress <------------------------------- Backend Server
```
By setting `brokerMode` to `true`. MQTTProxy can both send msg to backend and subscribers. Users can also send msg to clients by using HTTP endpoint.

# Example
Save following yaml to file `mqttproxy.yaml` and then run
```bash
Expand All @@ -60,6 +73,8 @@ rules:
- when:
packetType: Publish
pipeline: pipeline-mqtt-publish
# by default, brokerMode is disabled.
brokerMode: true

---

Expand Down
Loading

0 comments on commit cd42976

Please sign in to comment.