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

Nonblocking Subscribe/Unsubscribe #278

Open
thedevop opened this issue Nov 23, 2024 · 3 comments
Open

Nonblocking Subscribe/Unsubscribe #278

thedevop opened this issue Nov 23, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@thedevop
Copy link
Contributor

thedevop commented Nov 23, 2024

Is your feature request related to a problem? Please describe.
In a high volume environment, the blocking nature of subscribe/unsubscribe creates a bottleneck.

Describe the solution you'd like
Add SubscribeWithOptions and UnsubscribeWithOptions like PublishWithOptions. This ensures the order is preserved hitting the wire, but without holding up the application waiting on response. It can either return result via a callback or a channel.

Describe alternatives you've considered
Call subscribe/unsubscribe in Go routines, however, this cannot guarantee the order.
Subscribe/Unsubscribe cannot be mixed in a single batch call.

@MattBrittan MattBrittan added the enhancement New feature or request label Nov 24, 2024
@MattBrittan
Copy link
Contributor

PublishWithOptions does not currently provide any notification that a message has actually been sent, it just retuns without waiting for a response (if the connection has been setup properly, and the session store is persistent, then it's reasonable to assume it will be sent at some point).
I'm open to this change, but it's not something I plan on implementing myself. One complicating factor is determining what to do when the connection is lost (and whether such publish requests should survice an application restart).

@thedevop
Copy link
Contributor Author

In my use case, the subscription does not need to survive connection lost. A new paho client will be created, and the application will manage the subscriptions. I will provide an implementation for review.

@MattBrittan
Copy link
Contributor

In my use case,

That's the challange because the library needs to support a range of use cases (I'm often surprised by how the library is used!). I think that, at a minimum, the callback would need to be called (passed some kind of error) for all pending requests when the connection is lost (otherwise users are likely to be left with goroutines waiting on something that will never happen).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants