Redis PubSub ServiceStack,取消线程

Redis PubSub ServiceStack,取消线程,第1张

Redis Pub / Sub ServiceStack,取消线程

RedisMqServer中的示例显示了如何订阅和取消订阅消息,例如:

using (var subscription = redisClient.CreateSubscription()){    subscription.onUnSubscribe = channel =>         Log.Debug("OnUnSubscribe: " + channel);    subscription.onMessage = (channel, msg) =>    {        if (msg == "STOP")        { Log.Debug("Stop Command Issued"); Log.Debug("Unsubscribing from all Channels..."); subscription.UnSubscribeFromAllChannels(); //Unblocks thread.        }    };    subscription.SubscribeToChannels(QueueNames.TopicIn); //blocks thread}

它使用自定义控制消息来取消阻止后台线程,并取消订阅 OnMessage 处理程序的所有通道的订阅。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4973578.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-13

发表评论

登录后才能评论

评论列表(0条)

保存