Class DefaultCheckpointMetadata<T>

java.lang.Object
io.smallrye.reactive.messaging.kafka.commit.DefaultCheckpointMetadata<T>
Type Parameters:
T - type of the processing state
All Implemented Interfaces:
CheckpointMetadata<T>

public class DefaultCheckpointMetadata<T> extends Object implements CheckpointMetadata<T>
Default implementation of CheckpointMetadata
  • Constructor Details

    • DefaultCheckpointMetadata

      public DefaultCheckpointMetadata(org.apache.kafka.common.TopicPartition topicPartition, long recordOffset, KafkaCheckpointCommit.CheckpointState<T> checkpointState)
  • Method Details

    • fromMessage

      public static <S> DefaultCheckpointMetadata<S> fromMessage(org.eclipse.microprofile.reactive.messaging.Message<?> message)
    • getTopicPartition

      public org.apache.kafka.common.TopicPartition getTopicPartition()
      Specified by:
      getTopicPartition in interface CheckpointMetadata<T>
      Returns:
      the topic-partition of this record
    • getRecordOffset

      public long getRecordOffset()
      Specified by:
      getRecordOffset in interface CheckpointMetadata<T>
      Returns:
      the offset of this record
    • isPersistOnAck

      public boolean isPersistOnAck()
      Specified by:
      isPersistOnAck in interface CheckpointMetadata<T>
      Returns:
      true if the processing state will be persisted on message acknowledgement
    • getCurrent

      public ProcessingState<T> getCurrent()
      Specified by:
      getCurrent in interface CheckpointMetadata<T>
      Returns:
      the current processing state
    • getNext

      public ProcessingState<T> getNext()
      Specified by:
      getNext in interface CheckpointMetadata<T>
      Returns:
      the next processing state set during this processing
    • setNext

      public T setNext(T state, boolean persistOnAck)
      Description copied from interface: CheckpointMetadata
      Set the next processing state to the given state, associated with the current record offset + 1.
      Specified by:
      setNext in interface CheckpointMetadata<T>
      Parameters:
      state - the next state
      persistOnAck - If true then the state will be persisted on message acknowledgement
      Returns:
      the previous state
    • setNext

      public T setNext(T state)
      Description copied from interface: CheckpointMetadata
      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.
      Specified by:
      setNext in interface CheckpointMetadata<T>
      Parameters:
      state - the next state
      Returns:
      the previous state
    • transform

      public T transform(Supplier<T> initialStateSupplier, Function<T,T> transformation, boolean persistOnAck)
      Description copied from interface: CheckpointMetadata
      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.
      Specified by:
      transform in interface CheckpointMetadata<T>
      Parameters:
      initialStateSupplier - if no previous state does exist, start the transformation from this state.
      transformation - the transformation function
      persistOnAck - If true then the state will be persisted on message acknowledgement
      Returns:
      the previous state
    • transform

      public T transform(T initialState, Function<T,T> transformation, boolean persistOnAck)
      Description copied from interface: CheckpointMetadata
      Specified by:
      transform in interface CheckpointMetadata<T>
      Parameters:
      initialState - if no previous state does exist, start the transformation from this state.
      transformation - the transformation function
      persistOnAck - If true then the state will be persisted on message acknowledgement
      Returns:
      the previous state
    • transform

      public T transform(Supplier<T> initialStateSupplier, Function<T,T> transformation)
      Description copied from interface: CheckpointMetadata
      See CheckpointMetadata.transform(Supplier, Function, boolean) The state will not be persisted on message acknowledgement.
      Specified by:
      transform in interface CheckpointMetadata<T>
      Parameters:
      initialStateSupplier - if no previous state does exist, start the transformation from this state.
      transformation - the transformation function
      Returns:
      the previous state
    • transform

      public T transform(T initialState, Function<T,T> transformation)
      Description copied from interface: CheckpointMetadata
      See CheckpointMetadata.transform(Supplier, Function, boolean) The state will not be persisted on message acknowledgement.
      Specified by:
      transform in interface CheckpointMetadata<T>
      Parameters:
      initialState - if no previous state does exist, start the transformation from this state.
      transformation - the transformation function
      Returns:
      the previous state