Bridge data to MQTT Broker

Setup anther MQTT broker using mosquitto, change the port to 2883. Taking Mac OSX for instance:

  1. $ brew install mosquitto
  2. $ vim /usr/local/etc/mosquitto/mosquitto.conf
  3. port 2883
  4. # start mosquitto
  5. $ brew services start mosquitto

Create a rule:

Go to EMQ X DashboardMQTT Broker Bridges - 图1 (opens new window), select the “rule” tab on the menu to the left.

Select “message.publish”, then type in the following SQL:

  1. SELECT
  2. *
  3. FROM
  4. "message.publish"

image

Bind an action:

  1. Click on the "+ Add" button under "Action Handler", and then select
  2. "Data bridge to MQTT Broker" in the pop-up dialog window.

image

Bind a resource to the action. Since the dropdown list “Resource” is empty for now, we create a new resource by clicking on the “New Resource” to the top right, and then select “MQTT Bridge”:

image

Configure the resource:

  1. Set "Broker Address" to the address of mosquitto, here is
  2. 127.0.0.1:2883, and keep all other configs as default, and click on
  3. the "Testing Connection" button to make sure the connection can be
  4. created successfully, and then click on the "Create" button.

image

Back to the “Actions” dialog, and then click on the “Confirm” button.

image

Back to the creating rule page, then click on “Create” button. The rule we created will be show in the rule list:

image

We have finished, testing the rule by sending an MQTT message to emqx:

  1. Topic: "t/1"
  2. QoS: 0
  3. Retained: false
  4. Payload: "Hello, World\!"

Then verify a message has been published to mosquitto:

image

And from the rule list, verify that the “Matched” column has increased to 1:

image