訊息訂閱 10

2021-08-02 16:21:17 字數 1142 閱讀 2682

訊息訂閱

發布端: publish 頻道名稱 發布內容

訂閱端:

subscribe 頻道名稱,頻道名稱…;

psubscribe  頻道名稱正則

unsubscribe [channel [channel …]]客戶端退訂給定的頻道。沒有引數,所有頻道都會被退訂

punsubscribe [pattern [pattern …]]指示客戶端退訂所有給定模式的頻道。

案列

--訂閱:

127.0.0.1:6379> subscribe news1 news2

reading messages... (press ctrl-c to quit)

1) "message"

2) "news2"

3) "111"

1) "message"

2) "news1"

3) "222"

--發布:

127.0.0.1:6379> publish news2 '111'

(integer) 1

127.0.0.1:6379> publish news1 '222'

(integer) 1

--訂閱:

127.0.0.1:6379> psubscribe news*

reading messages... (press ctrl-c to quit)

1) "psubscribe"

2) "news*"

3) (integer) 1

1) "pmessage"

2) "news*"

3) "news1"

4) "1"

1) "pmessage"

2) "news*"

3) "news2"

4) "2"

--發布

127.0.0.1:6379> publish news1 '1'

(integer) 1

127.0.0.1:6379> publish news2 '2'

(integer) 1

127.0.0.1:6379>

Redis之訊息訂閱

程序間的訊息通訊模式,傳送者 pub 傳送訊息,訂閱者 sub 接收訊息,如下圖所示 publish發布訊息 127.0.0.1 6379 publish c1 hello integer 0 127.0.0.1 6379 publish c1 hi integer 1 subscribe訂閱訊息,...

小程式 訊息訂閱

desc 小程式訂閱功能 param tmplids 訂閱列表 returns 返回promise 永久關閉訂閱則代表點選了我不在接受此訊息,再次訂閱是無法彈起授權視窗的。普通關閉時可以再次彈起授權視窗。export const subscribe tmplids 申請訂閱功能 function r...

mysql訊息訂閱與發布 發布 訂閱配置

public ibus bus public void handle mymessage message bus.publish e e.someproperty xyz 公共汽車 屬性將自動由基礎設施。這就是所謂的 依賴注入 所有開發完成了nservicebus利用這些模式。技術作為nservic...