Get subscription relationship from MongoDB

    Create the mqtt_sub table:

    Create rules:

    Open EMQX Dashboard (opens new window) and select the “Rules” tab on the left.

    Then fill in the rule SQL:

    image-20211214142714391

    Related actions:

    Select “Add Action” on the “Response Action” interface, and then select “Get Subscription List from MongoDB” in the “Add Action” drop-down box

    The action of “Get subscription list from MongoDB” requires one parameter:

    1). Associated resources. The resource drop-down box is empty now, and you can click “New” in the upper right corner to create a MongoDB resource:

    image-20211214142840878

    The “Create Resource” dialog box pops up

    Fill in the resource configuration:

    Fill in the real MongoDB server address and the values corresponding to other configurations, and then click the “Test Connection” button to ensure that the connection test is successful.

    Finally click the “OK” button.

    Return to the response action interface and click “OK”.

    image-20211214143347354

    Return to the rule creation interface and click “Create”.

    The rule has been created, and you can insert a subscription relationship into MongoDB through “mongo”:

    Get subscription from MongoDB - 图9

    Log in to the device whose clientid is test via Dashboard:

    image-20211214143528939