【发布时间】:2014-12-10 01:36:33
【问题描述】:
想象一个场景,我们有许多生产者和一个消费者。消费者订阅了一个名为“consumerGroup”的频道组。生产者每次进入系统,都会将频道“Producer-ID-Channel”加入consumerGroup,订阅频道并发布消息。
消费者是否会自动订阅该频道,因为他已经订阅了它所属的组?即使制作人的频道是在他最初订阅组的时间之后添加到组中的?
【问题讨论】:
标签: pubnub
想象一个场景,我们有许多生产者和一个消费者。消费者订阅了一个名为“consumerGroup”的频道组。生产者每次进入系统,都会将频道“Producer-ID-Channel”加入consumerGroup,订阅频道并发布消息。
消费者是否会自动订阅该频道,因为他已经订阅了它所属的组?即使制作人的频道是在他最初订阅组的时间之后添加到组中的?
【问题讨论】:
标签: pubnub
是的!客户端需要做的就是订阅频道组,当频道通过任何方式添加/删除到频道组时,客户端都会收到它们。
在 JavaScript 上,如果您的消息回调如下所示:
function cb(message, envelope, channel){
/* message will contain the message
envelope will contain the server-response, in which data like message and channel are
derived from.
element 0 will be the current message in the callback cycle
(also accessible via 'message')
element 1 will be the timetoken of the server response
element 2 will be the channel group name the message arrived on
element 3 will be the actual channel within the channel group the msg arrived on */
}
杰瑞米
【讨论】: