Is there a way to automatically unsubscribe from a channel in Redis?

Viewed 185

I have simple code that subscribes to a channel, receives one message and then unsubscribes.

I am using Stackexchange.Redis that has as far as I can see one connection to Redis for subscriptions.

The method that i described will be called by multiple threads simultaneously and the channel is dynamic. What I am wondering is what's going to happen if one of the threads cannot perform the unsubscribe (due to an exception e.g.).

If this keeps going on I'll have a lot of useless stale subscriptions that noone is listening to since from what I understand subscription is not closed after ChannelMessageQueue goes out of scope and is garbage collected eventually.

Is there a good way to handle this situation?

0 Answers
Related