You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Consume func allows for several options, including PullMaxMessages. However, PullMaxMessages defaults to 500 if not provided as an option here. At the same time, when creating a consumer in the first place, the config allows for setting MaxRequestBatch. If MaxRequestBatch is less than PullMaxMessages then the Consume func will always fail with error nats: Exceeded MaxRequestBatch of X. Additionally, this error is only exposed if passing the optional jetstream.ConsumeErrHandler to expose it - otherwise the consumer will silently fail to consume anything.
Expected behavior
The Consume func should inherit default values (such as PullMaxMessages) from the consumer config, or otherwise not allow this situation to begin with.
The Consume func should return a non-nil error if the options make consuming impossible (such as a consumer with MaxRequestBatch less than the set PullMaxMessages if that's still a option after fixing (1))
Hey @wood-jp, thank's for reporting the issue. You're right, we should be taking consumer config into account on Consume. I think adjusting the default is reasonable, the only risk is that the consumer may be updated asynchronously between when you creating/fetchcing the consumer info and calling Consume (update may change e.g. MaxRequestBatch).
Observed behavior
The Consume func allows for several options, including
PullMaxMessages
. However,PullMaxMessages
defaults to 500 if not provided as an option here. At the same time, when creating a consumer in the first place, the config allows for setting MaxRequestBatch. IfMaxRequestBatch
is less thanPullMaxMessages
then theConsume
func will always fail with errornats: Exceeded MaxRequestBatch of X
. Additionally, this error is only exposed if passing the optionaljetstream.ConsumeErrHandler
to expose it - otherwise the consumer will silently fail to consume anything.Expected behavior
Consume
func should inherit default values (such asPullMaxMessages
) from the consumer config, or otherwise not allow this situation to begin with.Consume
func should return a non-nil error if the options make consuming impossible (such as a consumer withMaxRequestBatch
less than the setPullMaxMessages
if that's still a option after fixing (1))Server and client version
github.com/nats-io/nats-server/v2 v2.10.12
github.com/nats-io/nats.go v1.33.1
Host environment
No response
Steps to reproduce
A full example requires some fiddling, but here's the short version:
Results in no handled messages, and outputs the error
nats: Exceeded MaxRequestBatch of 1
The text was updated successfully, but these errors were encountered: