Interface CheckpointMetadata<T>
- Type Parameters:
T
- type of the processing state
- All Known Implementing Classes:
DefaultCheckpointMetadata
public interface CheckpointMetadata<T>
Checkpoint metadata type for injecting state checkpointing interactions into received messages.
This allows accessing the current processing state restored from the state store, and produce the next state.
The next state can be saved locally or persisted into the external store.
A sample processing method with checkpointing would be:
@Incoming("in") public CompletionStage<Void> process(Message<String> msg) { CheckpointMetadata<Integer> checkpoint = CheckpointMetadata.fromMessage(msg); if (checkpoint != null) { checkpoint.transform(0, current -> current + msg.getPayload()); } return CompletableFuture.completed(null); }
-
Method Summary
Modifier and TypeMethodDescriptionstatic <S> CheckpointMetadata<S>
fromMessage
(org.eclipse.microprofile.reactive.messaging.Message<?> message) getNext()
long
org.apache.kafka.common.TopicPartition
boolean
Set the next processing state to the given state, associated with the current record offset + 1.Set the next processing state to the given state, associated with the current record offset + 1.Seetransform(Supplier, Function, boolean)
The state will not be persisted on message acknowledgement.Apply the transformation to the current state, if a previous state doesn't exist, start the transformation from the supplied initial state.Seetransform(Supplier, Function, boolean)
The state will not be persisted on message acknowledgement.
-
Method Details
-
fromMessage
static <S> CheckpointMetadata<S> fromMessage(org.eclipse.microprofile.reactive.messaging.Message<?> message) -
getTopicPartition
org.apache.kafka.common.TopicPartition getTopicPartition()- Returns:
- the topic-partition of this record
-
getRecordOffset
long getRecordOffset()- Returns:
- the offset of this record
-
isPersistOnAck
boolean isPersistOnAck()- Returns:
true
if the processing state will be persisted on message acknowledgement
-
getCurrent
ProcessingState<T> getCurrent()- Returns:
- the current processing state
-
getNext
ProcessingState<T> getNext()- Returns:
- the next processing state set during this processing
-
setNext
Set the next processing state to the given state, associated with the current record offset + 1.- Parameters:
state
- the next statepersistOnAck
- Iftrue
then the state will be persisted on message acknowledgement- Returns:
- the previous state
-
setNext
Set the next processing state to the given state, associated with the current record offset + 1. The state will not be persisted on message acknowledgement.- Parameters:
state
- the next state- Returns:
- the previous state
-
transform
Apply the transformation to the current state, if a previous state doesn't exist, start the transformation from the supplied initial state. The state will be associated with the current record offset + 1.- Parameters:
initialStateSupplier
- if no previous state does exist, start the transformation from this state.transformation
- the transformation functionpersistOnAck
- Iftrue
then the state will be persisted on message acknowledgement- Returns:
- the previous state
-
transform
- Parameters:
initialState
- if no previous state does exist, start the transformation from this state.transformation
- the transformation functionpersistOnAck
- Iftrue
then the state will be persisted on message acknowledgement- Returns:
- the previous state
-
transform
Seetransform(Supplier, Function, boolean)
The state will not be persisted on message acknowledgement.- Parameters:
initialStateSupplier
- if no previous state does exist, start the transformation from this state.transformation
- the transformation function- Returns:
- the previous state
-
transform
Seetransform(Supplier, Function, boolean)
The state will not be persisted on message acknowledgement.- Parameters:
initialState
- if no previous state does exist, start the transformation from this state.transformation
- the transformation function- Returns:
- the previous state
-