From 0c3f4642170267bdbce8b9d5a3473e55f636b784 Mon Sep 17 00:00:00 2001 From: SammyOina Date: Wed, 26 Jul 2023 12:44:08 +0300 Subject: [PATCH 1/3] update documentation for export test Signed-off-by: SammyOina --- docs/edge.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/edge.md b/docs/edge.md index 29945aff..1b68fe44 100644 --- a/docs/edge.md +++ b/docs/edge.md @@ -530,9 +530,8 @@ cd build #### Testing Export ```bash -git clone https://github.com/nats-io/nats.go -cd github.com/nats-io/nats.go/examples/nats-pub -go run main.go -s http://localhost:4222 export.test "[{\"bn\":\"test\"}]"; +git clone https://github.com/mainflux/agent +go run -tags nats ./examples/publish/main.go -s http://localhost:4222 export.test "[{\"bn\":\"test\"}]"; ``` We have configured route for export, `nats_topic = ">"` means that it will listen to `NATS` subject `export.>` and `mqtt_topic` is configured so that data will be sent to MQTT broker on topic `channels/e2adcfa6-96b2-425d-8cd4-ff8cb9c056ce/messages` with appended `NATS` subject. From c230adeceb67e65d0a8ed892a76f7faa1b0267a6 Mon Sep 17 00:00:00 2001 From: SammyOina Date: Tue, 1 Aug 2023 16:26:53 +0300 Subject: [PATCH 2/3] remove tags arg Signed-off-by: SammyOina --- docs/edge.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/edge.md b/docs/edge.md index 1b68fe44..1aa0c260 100644 --- a/docs/edge.md +++ b/docs/edge.md @@ -531,17 +531,19 @@ cd build #### Testing Export ```bash git clone https://github.com/mainflux/agent -go run -tags nats ./examples/publish/main.go -s http://localhost:4222 export.test "[{\"bn\":\"test\"}]"; +go run ./examples/publish/main.go -s http://localhost:4222 export.test "[{\"bn\":\"test\"}]"; ``` -We have configured route for export, `nats_topic = ">"` means that it will listen to `NATS` subject `export.>` and `mqtt_topic` is configured so that data will be sent to MQTT broker on topic `channels/e2adcfa6-96b2-425d-8cd4-ff8cb9c056ce/messages` with appended `NATS` subject. +We have configured route for export, `nats_topic = ">"` means that it will listen to `NATS` subject `export.>` and `mqtt_topic` is configured so that data will be sent to MQTT broker on topic `channels/e2adcfa6-96b2-425d-8cd4-ff8cb9c056ce/messages` with appended `NATS` subject. Depending on the broker used, nats by default, rabbitmq can be used by setting the build tag to `rabbitmq`. In terminal where export is started you should see following message: + ```log {"level":"debug","message":"Published to: export.test, payload: [{\"bn\":\"test\"}]","ts":"2020-05-08T15:14:15.757298992Z"} ``` In Mainflux `mqtt` service: + ```log mainflux-mqtt | {"level":"info","message":"Publish - client ID export-88529fb2-6c1e-4b60-b9ab-73b5d89f7404 to the topic: channels/e2adcfa6-96b2-425d-8cd4-ff8cb9c056ce/messages/export/test","ts":"2020-05-08T15:16:02.999684791Z"} ``` From d422ddbbf81d588b2198fd6540c688812a5d6f3b Mon Sep 17 00:00:00 2001 From: SammyOina Date: Tue, 1 Aug 2023 22:00:18 +0300 Subject: [PATCH 3/3] update dev guide description Signed-off-by: SammyOina --- docs/dev-guide.md | 18 ++++++++++++------ docs/edge.md | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/dev-guide.md b/docs/dev-guide.md index f316ee32..73f89d2d 100644 --- a/docs/dev-guide.md +++ b/docs/dev-guide.md @@ -226,22 +226,28 @@ which will do this copying of the binaries. Mainflux depends on several infrastructural services, notably the default message broker, [NATS](https://www.nats.io/) and [PostgreSQL](https://www.postgresql.org/) database. #### Message Broker + Mainflux uses NATS as it's default central message bus. For development purposes (when not run via Docker), it expects that NATS is installed on the local system. To do this execute: -``` -go get github.com/nats-io/gnatsd +```bash +go install github.com/nats-io/nats-server/v2@latest ``` -This will install `gnatsd` binary that can be simply run by executing: +This will install `nats-server` binary that can be simply run by executing: -``` -gnatsd +```bash +nats-server ``` -If you want to change the default message broker to [RabbitMQ](https://www.rabbitmq.com/download.html), [VerneMQ](https://vernemq.com/downloads/) or [Kafka](https://kafka.apache.org/quickstart) you need to install it on the local system. +If you want to change the default message broker to [RabbitMQ](https://www.rabbitmq.com/download.html) or [VerneMQ](https://vernemq.com/downloads/) you need to install it on the local system. +To run using a different broker you need to set the `MF_BROKER_TYPE` env variable to `nats`, `rabbitmq` or `vernemq` during make and run process. +```bash +MF_BROKER_TYPE= make +MF_BROKER_TYPE= make run +``` #### PostgreSQL Mainflux uses PostgreSQL to store metadata (`users`, `things` and `channels` entities alongside with authorization tokens). diff --git a/docs/edge.md b/docs/edge.md index 1aa0c260..c07a3845 100644 --- a/docs/edge.md +++ b/docs/edge.md @@ -534,7 +534,7 @@ git clone https://github.com/mainflux/agent go run ./examples/publish/main.go -s http://localhost:4222 export.test "[{\"bn\":\"test\"}]"; ``` -We have configured route for export, `nats_topic = ">"` means that it will listen to `NATS` subject `export.>` and `mqtt_topic` is configured so that data will be sent to MQTT broker on topic `channels/e2adcfa6-96b2-425d-8cd4-ff8cb9c056ce/messages` with appended `NATS` subject. Depending on the broker used, nats by default, rabbitmq can be used by setting the build tag to `rabbitmq`. +We have configured route for export, `nats_topic = ">"` means that it will listen to `NATS` subject `export.>` and `mqtt_topic` is configured so that data will be sent to MQTT broker on topic `channels/e2adcfa6-96b2-425d-8cd4-ff8cb9c056ce/messages` with appended `NATS` subject. Other brokers can such as `rabbitmq` can be used, for more detail refer to [dev-guide][dev-guide]. In terminal where export is started you should see following message: @@ -553,3 +553,4 @@ mainflux-mqtt | {"level":"info","message":"Publish - client ID export-88529fb2 [env]:(https://github.com/mainflux/export#environmet-variables) [agent]:(https://github.com/mainflux/agent) [protomsg]:https://github.com/mainflux/mainflux/blob/master/pkg/messaging/message.proto +[dev-guide]: /docs/dev-guide.md/#message-broker