Skip to content

EMQX DEMO

Operation environment: JAVA17, EMQX5.8 open source version, Redis6+
Open external network ports: 1883 (mqtt), 18083 (emqx api), 9010 (java api)
EMQX documentation: https://docs.emqx.com/zh/emqx/v5.8/

Install EMQX

https://docs.emqx.com/zh/emqx/v5.8/deploy/install-open-source.html

2、Set language

3、Create API key


4、Create client authentication



5、Create rules

5.1 Create rules rule_message


text
SELECT
  *, base64_encode(payload) as payload
FROM
  "#",
  "$events/message_delivered"

5.2 Create rules rule_event

text
SELECT
  *
FROM
  "$events/client_connected",
  "$events/client_disconnected",
  "$events/session_subscribed",
  "$events/session_unsubscribed"

5.3 Create a connector http_message



text
http://127.0.0.1:9010/powerbank-protocol-v1/emqx/message

5.4 Create a connector http_event


text
http://127.0.0.1:9010/powerbank-protocol-v1/emqx/event

6、Set rule actions ac_message




7、Set rule actions ac_event




8、Configure spirngboot

text
spring:
  data:
    # redis service address
    redis:
      port: 6379
      host: 127.0.0.1

emqx:
  mqtt:
     # Used for the device MQTT connection address, which must be accessible from the external network. The server needs to open port
    url: mqtt.alascloud.com
    port: 1883
  api:
    # API user key
    url: http://localhost:18083/api/v5
    username: ee26b0dd4af7e749
    password: OgNVogSs9BqYduxSJPkGx1GggrNaKdDIlM2pZUuYxMcF

notifyList:
  # Configure all message callback addresses (test)
  - url: http://localhost:9010/powerbank-protocol-v1/notify/test/iot
    timeout: 15000
    enabled: true

9、Start the project

text
java -jar powerbank-protocol-1.0-SNAPSHOT.jar
text
API                :   http://127.0.0.1:9010/powerbank-protocol-v1
Swagger Document   :   http://127.0.0.1:9010/powerbank-protocol-v1/doc.html