Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

Awesome Lists containing this project

README

        


logo


Notifier

Creating 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
```