root@sjfw27:/etc/mosquitto# vim mosquitto.conf
root@sjfw27:/etc/mosquitto# mosquitto -c /etc/mosquitto/mosquitto.conf -d
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/room1/temperature -m '26.3'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/temperature -m '26.3'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/temperature -m '1收不到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/1 -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/1 -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/1 -m '1收到和其他#收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/temperature -m '1收不到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/temperature -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/1 -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/2 -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/2 -m '2收到'
root@sjfw27:/etc/mosquitto# vim mosquitto.conf
root@sjfw27:/etc/mosquitto# mosquitto -c /etc/mosquitto/mosquitto.conf -d
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/room1/temperature -m '26.3'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/temperature -m '26.3'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/temperature -m '1收不到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/1 -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/1 -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/1 -m '1收到和其他#收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/temperature -m '1收不到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/temperature -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/1 -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/2 -m '1收到'
root@sjfw27:/etc/mosquitto# mosquitto_pub -t sensor/topic1/2 -m '2收到'
root@sjfw27:/etc/mosquitto# ^c
root@sjfw27:/etc/mosquitto#
root@sjfw28:/etc/mosquitto# mosquitto -c /etc/mosquitto/mosquitto.conf -d
root@sjfw28:/etc/mosquitto# mosquitto_sub -t helloword
hello word
wangshumin
^croot@sjfw28:/etc/mosquitto# mosquitto -c /etc/mosquitto/mosquitto.conf -d
root@sjfw28:/etc/mosquitto# mosquitto_sub -t myhouse/topic1/#
26.3
^croot@sjfw28:/etc/mosquitto# mosquitto -c /etc/mosquitto/mosquitto.conf -d
root@sjfw28:/etc/mosquitto# mosquitto_sub -t myhouse/topic1/1
1收到^c
root@sjfw28:/etc/mosquitto# mosquitto_sub -t myhouse/topic1/1
^croot@sjfw28:/etc/mosquitto# mosquitto_sub -t myhouse/topic1/1
1收到1收到和其他#收到
^croot@sjfw28:/etc/mosquitto# mosquitto_sub -t myhouse/topic1/1
1收到
Redis 發布和訂閱
發布與訂閱 又稱pub sub 訂閱者 listener 負責訂閱頻道 channel 傳送者 publisher 負責向頻道傳送二進位制字串訊息 binary string message 每當有訊息被傳送給指定頻道的時候,頻道都所有訂閱者都會收到訊息。redis提供都5個發布訂閱命令 命令描述 ...
Python redis 訂閱和發布
發布和訂閱 首先定義乙個redishelper類,連線redis,定義頻道為monitor,定義發布 publish 及訂閱 subscribe 方法。usr bin env python coding utf 8 import redis class redishelper object def ...
Redis 發布和訂閱
一 概述 1 發布和訂閱是一種訊息通訊模式。2 優點 使訊息訂閱者和訊息發布者耦合度降低,類似設計模式中的觀察者模式。二 發布和訂閱 訂閱命令 訂閱乙個或多個頻道 返回值 value 1 為 subcribe 表示訂閱成功,value 2 為訂閱的頻道名稱,value 3 表示當前訂閱的頻道個數 s...