-
Notifications
You must be signed in to change notification settings - Fork 5
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
Throw TimeoutException when loading next even for aggregate takes too long #210
Throw TimeoutException when loading next even for aggregate takes too long #210
Conversation
src/main/java/io/axoniq/axonserver/connector/event/impl/BufferedAggregateEventStream.java
Outdated
Show resolved
Hide resolved
src/main/java/io/axoniq/axonserver/connector/impl/FlowControlledBuffer.java
Outdated
Show resolved
Hide resolved
src/main/java/io/axoniq/axonserver/connector/impl/FlowControlledBuffer.java
Outdated
Show resolved
Hide resolved
src/main/java/io/axoniq/axonserver/connector/impl/FlowControlledBuffer.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All nits, but 7 nits on a small PR to me constitutes in a request for changes.
src/main/java/io/axoniq/axonserver/connector/event/impl/BufferedAggregateEventStream.java
Outdated
Show resolved
Hide resolved
src/main/java/io/axoniq/axonserver/connector/event/impl/BufferedAggregateEventStream.java
Show resolved
Hide resolved
src/main/java/io/axoniq/axonserver/connector/event/impl/BufferedAggregateEventStream.java
Outdated
Show resolved
Hide resolved
@@ -31,12 +34,15 @@ | |||
implements AggregateEventStream { | |||
|
|||
private static final Event TERMINAL_MESSAGE = Event.newBuilder().setAggregateSequenceNumber(-1729).build(); | |||
private static final int TIMEOUT_MILLIS = Integer.parseInt(System.getProperty("AGGREGATE_TAKE_EVENT_TIMEOUT_MILLIS", | |||
"10000")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I wouldn't expect the 10000 default to be on a different line honestly. Differently put, indentation is a little off here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a coding standard, so it's intellij default column width. Pain in the behind for stuff like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I adjusted it as well I could
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should start a code style...I've got something in mind for stuff like this, but that's my OCD doing that; not a rule set.
try { | ||
return tryTake(timeout, timeUnit, false); | ||
} catch (TimeoutException e) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought: isn't it worth logging this scenario, perhaps just on debug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an impossible scenario, it's only there because java enforces the checked exceptions. The third parameter having false indicates it should never throw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the API, so the catch is no longer needed
src/main/java/io/axoniq/axonserver/connector/impl/FlowControlledBuffer.java
Outdated
Show resolved
Hide resolved
src/test/java/io/axoniq/axonserver/connector/event/impl/BufferedAggregateEventStreamTest.java
Show resolved
Hide resolved
…edBuffer.java Co-authored-by: Steven van Beelen <steven.vanbeelen@axoniq.io>
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
In some very special cases it seems the aggregate keeps loading indefinitely. This PR puts a timeout, by default 10 seconds, on waiting for the next event in the stream.
This timeout can be customized using the
AGGREGATE_TAKE_EVENT_TIMEOUT_MILLIS
system property.