Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedisMessageBus seems not reliable when subscriber is down #10

Open
ybdev opened this issue Apr 11, 2019 · 5 comments
Open

RedisMessageBus seems not reliable when subscriber is down #10

ybdev opened this issue Apr 11, 2019 · 5 comments
Assignees
Labels

Comments

@ybdev
Copy link

ybdev commented Apr 11, 2019

Hello,

When testing Publish/Subscribe with RedisMessageBus i've got some reliability issues.

If you kill down the Subscriber, and publish some messages with the client et then restart de Subscriber, messages are not processed.

Any idea on this?
Thanks you in advance.

Best Regards.
Yoann

@ybdev
Copy link
Author

ybdev commented Apr 12, 2019

After reading the code, the subscription is automaticaly Unsubsrcibed on Dispose.

RedisMessageBus.cs

public override void Dispose() {
            base.Dispose();

            if (_isSubscribed) {
                using (_lock.Lock()) {
                    if (!_isSubscribed)
                        return;

                    bool isTraceLogLevelEnabled = _logger.IsEnabled(LogLevel.Trace);
                    if (isTraceLogLevelEnabled) _logger.LogTrace("Unsubscribing from topic {Topic}", _options.Topic);
                    _options.Subscriber.Unsubscribe(_options.Topic, OnMessage, CommandFlags.FireAndForget);
                    _isSubscribed = false;
                    if (isTraceLogLevelEnabled) _logger.LogTrace("Unsubscribed from topic {Topic}", _options.Topic);
                }
            }
        }

It sould be great to have an option in RedisMessageBusOptions.cs to allow subscription persistence.

@niemyjski
Copy link
Member

When you dispose of an instance it will unsubscribe the current instance. If you create a new message bus instance it will resubscribe. Message bus instances should be singletons (a single instance and long lived). If you have a scenario that's failing and not recovering, can you please create a unit test for us.

@ybdev
Copy link
Author

ybdev commented Apr 12, 2019

Actually, what i want is to keep published messages alive, even if previously subscribers are down. Then when subscribers restart, messages should be processed.

Using the sample in source code you can reproduce what i say.

  • Start SampleJobClient
  • Start SampleJob
  • Publish messages with the client. Theses messages are processed by the SampleJob subscriber.
  • Kill SampleJob
  • Continue publishing messages with the client
  • Restart SampleJob, pending messages are not processed : That's my problem.

@niemyjski
Copy link
Member

I guess this sums up what's going on here: https://stackoverflow.com/questions/6192177/redis-pub-sub-with-reliability and https://www.redisgreen.net/blog/pubsub-intro/ We've always treated it as if no one is listening then why keep the messages and it's worked for our use cases where we don't care about delivery guarantees for most of our messaging. That's not to say we shouldn't. It might be worth while to look into using redis streams instead. Have you investigated this?

@niemyjski
Copy link
Member

Just curious if you have investigated this further? Sorry about the long time between replies. Just would be good to get an action on this item.

@niemyjski niemyjski self-assigned this Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants