Class StopCondition
public final class StopCondition
extends java.lang.Object
receiver endpoints to
specify under which circumstances message consumption should stop.-
Method Summary
Modifier and Type Method Description static java.util.function.Predicate<ShardResponse>arrivalTimestampAfterNow()Returns a stop condition that is true if at least one message contained in theShardResponsehas arrived after creating the predicate.static java.util.function.Predicate<ShardResponse>arrivalTimestampAfterNow(java.time.Clock clock)Returns a stop condition that is true if at least one message contained in theShardResponsehas arrived after creating the predicate.static java.util.function.Predicate<ShardResponse>emptyResponse()Returns a stop condition that is true if theShardResponsedoes not contain any messages.static java.util.function.Predicate<ShardResponse>endOfChannel()Returns a stop condition that is true if the end-of-channel is reached.static java.util.function.Predicate<ShardResponse>shutdown()Do not stop message consumption until the application is shutting down.static java.util.function.Predicate<ShardResponse>timestamp(java.time.Instant timestamp)Returns a stop condition that is true after the given timestamp.static java.util.function.Predicate<ShardResponse>timestamp(java.time.Instant timestamp, java.time.Clock clock)Returns a stop condition that is true after the given timestamp.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
shutdown
Do not stop message consumption until the application is shutting down.- Returns:
- stop condition always returning false;
-
timestamp
Returns a stop condition that is true after the given timestamp.- Parameters:
timestamp- the point in time after which the predicate will return true.- Returns:
- stop condition
-
timestamp
public static java.util.function.Predicate<ShardResponse> timestamp(java.time.Instant timestamp, java.time.Clock clock)Returns a stop condition that is true after the given timestamp.- Parameters:
timestamp- the point in time after which the predicate will return true.clock- the clock used to get the current time- Returns:
- stop condition
-
arrivalTimestampAfterNow
Returns a stop condition that is true if at least one message contained in theShardResponsehas arrived after creating the predicate.- Returns:
- stop condition
-
arrivalTimestampAfterNow
public static java.util.function.Predicate<ShardResponse> arrivalTimestampAfterNow(java.time.Clock clock)Returns a stop condition that is true if at least one message contained in theShardResponsehas arrived after creating the predicate.- Parameters:
clock- the clock used to get the current time- Returns:
- stop condition
-
endOfChannel
Returns a stop condition that is true if the end-of-channel is reached.It is assumed that end-of-channel is reached if
ShardResponse.getDurationBehind()isDuration.ZERO, even ifShardResponse.getMessages()is not empty.Note that using this predicate as a stop condition for sharded message logs, the message consumption will stop after all shards have reached the end of the channels at least once.
- Returns:
- stop condition
-
emptyResponse
Returns a stop condition that is true if theShardResponsedoes not contain any messages.An empty
ShardResponsedoes not necessarily indicate that the end-of-channel is reached. Especially in case of Kinesis message logs it is possible that multipleShardResponsescontain no messages, while theShardResponse.getDurationBehind()is greaterZERO.You might want to combine this predicate with
endOfChannel()like this:StopCondition.endOfChannel().and(StopCondition.emptyResponse());Note that using this predicate as a stop condition for sharded message logs, the message consumption will stop after all shards have reached the end of the channels at least once.
- Returns:
- stop condition
-