public final class StopCondition
extends java.lang.Object
receiver endpoints to
specify under which circumstances message consumption should stop.| Modifier and Type | Method and Description |
|---|---|
static java.util.function.Predicate<ShardResponse> |
arrivalTimestampAfterNow()
Returns a stop condition that is true if at least one message contained in the
ShardResponse has 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 the
ShardResponse has arrived
after creating the predicate. |
static java.util.function.Predicate<ShardResponse> |
emptyResponse()
Returns a stop condition that is true if the
ShardResponse does 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.
|
public static java.util.function.Predicate<ShardResponse> shutdown()
public static java.util.function.Predicate<ShardResponse> timestamp(java.time.Instant timestamp)
timestamp - the point in time after which the predicate will return true.public static java.util.function.Predicate<ShardResponse> timestamp(java.time.Instant timestamp, java.time.Clock clock)
timestamp - the point in time after which the predicate will return true.clock - the clock used to get the current timepublic static java.util.function.Predicate<ShardResponse> arrivalTimestampAfterNow()
ShardResponse has arrived
after creating the predicate.public static java.util.function.Predicate<ShardResponse> arrivalTimestampAfterNow(java.time.Clock clock)
ShardResponse has arrived
after creating the predicate.clock - the clock used to get the current timepublic static java.util.function.Predicate<ShardResponse> endOfChannel()
It is assumed that end-of-channel is reached if ShardResponse.getDurationBehind() is
Duration.ZERO, even if ShardResponse.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.
public static java.util.function.Predicate<ShardResponse> emptyResponse()
ShardResponse does not contain any messages.
An empty ShardResponse does not necessarily indicate that the end-of-channel is reached.
Especially in case of Kinesis message logs it is possible that multiple ShardResponses contain
no messages, while the ShardResponse.getDurationBehind() is greater ZERO.
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.