RabbitMQ代理主题和消息列表

时间:2017-07-27 07:32:57

标签: rabbitmq mqtt messagebroker rabbitmq-exchange rabbitmqctl

我已经在localhost上安装的RabbitMQ代理上从Python客户端创建了一个MQTT主题。我在本主题中发布了一些消息,并且能够在用Python编写的订阅服务器中查看MQTTLens Chrome插件中的消息。 哪里可以看到在RabbitMQ代理中创建的主题列表?我已为此服务器启用了Web界面。但我无法看到"交换"标签 。请让我知道在哪里可以查看有关每个主题的主题和个别消息。

出版商:

import paho.mqtt.client as paho

broker = "localhost"
port = 1883


def on_publish(client, userdata, result):  # create function for callback
    print("message published \n",userdata,result)
    pass


client1 = paho.Client("client1")  # create client object
client1.on_publish = on_publish  # assign function to callback
client1.connect(broker, port)  # establish connection
ret = client1.publish("home", "test-message")  # publish

订阅者:

import paho.mqtt.client as paho

broker = "localhost"
port = 1883


def on_subscribe(client, userdata, ret, granted_qos):  # create function for callback
    print("started subscribing ... \n",userdata,ret)
    pass


def on_message(client, userdata, message):
    print("Received message '" + str(message.payload) + "' on topic '"
          + message.topic + "' with QoS " + str(message.qos))


client2 = paho.Client("client2")  # create client object
client2.on_subscribe = on_subscribe
client2.connect(broker, port)  # establish connection
ret = client2.subscribe(("home", 1))
client2.on_message = on_message
client2.loop_forever()

0 个答案:

没有答案