Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amirhnajafiz/notifier
Service for sending notifications.
https://github.com/amirhnajafiz/notifier
golang mqtt notification-service rabbitmq
Last synced: about 1 month ago
JSON representation
Service for sending notifications.
- Host: GitHub
- URL: https://github.com/amirhnajafiz/notifier
- Owner: amirhnajafiz
- Created: 2022-02-17T16:00:07.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-28T04:00:16.000Z (over 2 years ago)
- Last Synced: 2024-06-20T06:25:02.950Z (6 months ago)
- Topics: golang, mqtt, notification-service, rabbitmq
- Language: Go
- Homepage:
- Size: 185 KB
- Stars: 13
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
NotifierCreating a golang service for sending notifications using **MQTT**. The main idea
behind this service is to work with **RabbitMQ** in **Golang**.In this project, we have a notifier service (written in _golang_) that allows
us to send notifications to our clients using **MQTT**.By setting the _topic_, you can send data into different channels. On the other
hand, the clients will receive data from those channels.## What do you learn in this project?
- RabbitMQ## What is MQTT (RabbitMQ)?
MQTT (_MQ Telemetry Transport_) is a lightweight
open messaging protocol that provides resource-constrained
network clients with a simple way to distribute telemetry
information in low-bandwidth environments.The protocol, which employs a **publish/subscribe**
communication pattern, is used for machine-to-machine
(M2M) communication.Imagine the following example:
The temperature sensor (**publisher**) will send the data to _MQTT-broker_
and the broker will send the data to clients (**subscribers**).## How to use this project?
Run the application:
```shell
go run main.go
```Send the notifications with the following route:
```
URL: /api/send
Method: POST
Headers: Contenct-type: application/json
```body:
```json
{
"topic": "[optional]",
"message": "[data]"
}
```## Client testing
You can set **MQTT** options and configurations for your client,
but if you don't change anything in **config.json**, it still works.```go
func main() {
c := client.Client{
Cfg: load(),
IsSubscriber: true,
}.Register()if token := c.Connect(); token.Wait() && token.Error() != nil {
panic(token.Error())
}select {}
}
```## Deploy
Deploy the project on kubernetes cluster with the following command:
```shell
kubectl apply -f deployment/deployment.yml
``````shell
kubectl apply -f deployment/services.yml
```