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

unsubscribe with limit is missing on reconnect possibly, once the limit is hit too #293

Open
matthiashanel opened this issue Feb 5, 2020 · 0 comments

Comments

@matthiashanel
Copy link
Contributor

in go, on reconnect, a subscription with a limit is followed up by unsubscribe(max-received)
This can cause unnecessary traffic and unnecessarily dropped messages in queue subscribers.

void resendSubscriptions() {
this.subscriptionsUsingDefaultHandler.forEach((id, sub)->{
this.connection.sendSubscriptionMessage(sub.getSID(), sub.getSubject(), sub.getQueueName(), true);
});
this.subscriptionsWithHandlers.forEach((sid, sub)->{
this.connection.sendSubscriptionMessage(sub.getSID(), sub.getSubject(), sub.getQueueName(), true);
});
}

in Go:
https://github.com/nats-io/nats.go/blob/93a68d7e795f11c0aa30cfa38cf9a4702ae8d8b7/nats.go#L3591

This issue may be worse as, when the limit is actually hit no unsubscribe seems to occur.
These two methods call invalidate
NatsDispatcher.run() (io.nats.client.impl)
NatsSubscription.nextMessage(Duration) (io.nats.client.impl)

which does not seem to have unsubscribe in it's path. (sub.invalidate() does not either)

    void invalidate(NatsSubscription sub) {
        CharSequence sid = sub.getSID();

        subscribers.remove(sid);

        if (sub.getNatsDispatcher() != null) {
            sub.getNatsDispatcher().remove(sub);
        }

        sub.invalidate();
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant