Avoid using exceptions (like NATSTimeoutException) for flow control #599
robertmircea
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've noticed through nats.net code base that exceptions are consistently used for managing flow control for certain functions like
JetStreamAbstractSyncSubscription.NextMessage(int timeout)
. As far as I know, using exception for flow control and, especially, in tight loops like the ones which useNextMessage
is considered bad practices with performance implications.https://docs.microsoft.com/en-us/previous-versions/msp-n-p/ff647790(v=pandp.10)#do-not-use-exceptions-to-control-application-flow
For example,
NextMessage
throwsNATSTimeoutException
when no more message could be fetched. Would it be possible to offer overloaded signatures which do not throw exceptions?or better (to be consistent with .NET Core framework conventions)
This function would return
false
instead of throwingNATSTimeoutException
andtrue
when a message is available and will be returned asout
parameter.Beta Was this translation helpful? Give feedback.
All reactions