Class StopCondition
receiver endpoints to
specify under which circumstances message consumption should stop.-
Method Summary
Modifier and TypeMethodDescriptionstatic Predicate<ShardResponse>Returns a stop condition that is true if at least one message contained in theShardResponsehas arrived after creating the predicate.static Predicate<ShardResponse>arrivalTimestampAfterNow(Clock clock) Returns a stop condition that is true if at least one message contained in theShardResponsehas arrived after creating the predicate.static Predicate<ShardResponse>Returns a stop condition that is true if theShardResponsedoes not contain any messages.static Predicate<ShardResponse>Returns a stop condition that is true if the end-of-channel is reached.static Predicate<ShardResponse>shutdown()Do not stop message consumption until the application is shutting down.static Predicate<ShardResponse>Returns a stop condition that is true after the given timestamp.static Predicate<ShardResponse>Returns a stop condition that is true after the given timestamp.
-
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
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
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
-