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

Nats: guarantee order of message reception #58

Open
slawo opened this issue Mar 25, 2019 · 9 comments
Open

Nats: guarantee order of message reception #58

slawo opened this issue Mar 25, 2019 · 9 comments

Comments

@slawo
Copy link

slawo commented Mar 25, 2019

Currently there is no guarantee messages are received in order when using nats streaming.

This can be easily fixed by checking the msg.Sequence.

2 cases can be implemented:

  • SequenceGuarantee we receive the right sequence of events. 4,5,6,7,8...
  • OrderGuarantee: we receive the messages in order 4,5,8,9,30,31,34... which will work when group subscriptions are expected to be used.
@slawo
Copy link
Author

slawo commented Mar 27, 2019

One proposed solution is to create a flag Ordering which will be either Sequential, Ordered or None

@mjgarton
Copy link
Contributor

Why would we want this to be configurable? substrate, at the api level, guarantees order, and should do whatever it needs to make sure the underlying broker does that, and to error of not. We should not be exposing this choice to the consumer. If they don't want ordering, don't use substrate.

@slawo
Copy link
Author

slawo commented Apr 2, 2019

Because there are valid cases when using groups with multiple consumers where the sequential test will fail.

@slawo
Copy link
Author

slawo commented Apr 2, 2019

So maybe we can get rid of None, but we can keep Ordered and Sequential (default)

@mjgarton
Copy link
Contributor

mjgarton commented Apr 2, 2019

Why can't we expose no configuration, but always unconditionally check that the sequence is increasing and error if it goes down?

@ghost
Copy link

ghost commented Apr 5, 2019

That works when you have only one consumer.
But when you have many consumers each consumer will get messages only ordered ( 1,3,6,10,...) but never sequential ( 1.2.3.4,....).

@mjgarton
Copy link
Contributor

@gedw99 It's not clear to me which comment you were replying to.

@slawo @gedw99
If you request "sequential" and have multiple consumer instances running and using the same queue-group, what would you expect to happen in each consumer?

@mwain
Copy link
Contributor

mwain commented Mar 11, 2020

I didn't think Nats Streaming itself guaranteed message order?
Due to the way the server will attempt redelivery of messages it hasn't received an ack for?

@mjgarton
Copy link
Contributor

Yes, it's unfortunate, but nats-streaming "tries" to deliver in order, but there are cases where it does not.

We can't really fix that in substrate, but we might possibly detect it and protect the consumer from it by erroring or something. It's not clear whether it's worth the complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants