Configuration: EMQX to RabbitMQ
What is EMQX??
EMQ X (Erlang/Enterprise/Elastic MQTT Broker) is open source IoT MQTT message broker. It is based on Erlang/OTP. MQTT is a lightweight message exchange protocol using publish-subscribe pattern. EMQX support TCP / SSL connection support.
What is RabbitMQ??
RabbitMQ is a message broker or queue manager or we can say itis software where queues are defined. In that queues we can store our message and after that consume for further processing.
Before applying these configurations make sure you installed EMQX and RabbitMQ in your system.
Install EMQX → https://docs.emqx.io/broker/v3/en/install.html#
Install RabbitMQ →https://www.rabbitmq.com/install-debian.html
Commands to establish this feature:
Run below command in terminal$ rabbitmq-plugins enable rabbitmq_mqtt
Go to /etc/ location and insert below commands in emqx.conf file
## Bridge example
bridge.example.start_type = manual
bridge.example.reconnect_interval = 30s
bridge.example.address = 127.0.0.1:1883
bridge.example.proto_ver = mqttv4
bridge.example.client_id = bridge_example
bridge.example.username = admin
bridge.example.password = password
bridge.example.clean_start = false
bridge.example.keepalive = 60s
bridge.example.mountpoint = bridge/example/${node}/
Forward Topics
bridge.example.forwards = onlight/#
Subscription of Topic on Remote Node
bridge.example.subscription.1.topic = turnon/#
bridge.example.subscription.1.qos = 1
bridge.example.mqueue_type = memory
bridge.example.max_pending_messages = 10000
After saving these configuration run below commands to publish and subscribe the message…
For Subscriber: mosquitto_sub -t turnon/# -p 1883 -d
For Publisher: mosquitto_pub -t turnon/1/do -m "ON" -d
Output of the Subscriber:
Client mosqsub|14801-vaibhav-I sending CONNECT
Client mosqsub|14801-vaibhav-I received CONNACK
Client mosqsub|14801-vaibhav-I sending SUBSCRIBE (Mid: 1, Topic: turnon/#, QoS: 0)
Client mosqsub|14801-vaibhav-I received SUBACK
Subscribed (mid: 1): 0
Client mosqsub|14801-vaibhav-I received PUBLISH (d0, q0, r0, m0, ‘turnon/1/do’, … (2 bytes))
ON
Client mosqsub|14801-vaibhav-I sending PINGREQ
Client mosqsub|14801-vaibhav-I received PINGRESP
Happy Coding…..