Class StateStore<T>

  • Type Parameters:
    T - type of the processing state

    public class StateStore<T>
    extends Object
    State store metadata type for injecting state store 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) {
         StateStore<Integer> stateStore = StateStore.fromMessage(msg);
         if (stateStore != null) {
             stateStore.transformAndStoreOnAck(0, current -> current + msg.getPayload());
         }
         return CompletableFuture.completed(null);
     }
     
    • Constructor Detail

      • StateStore

        public StateStore​(org.apache.kafka.common.TopicPartition topicPartition,
                          long recordOffset,
                          Supplier<ProcessingState<T>> stateSupplier)
    • Method Detail

      • getProcessingState

        public static <S> ProcessingState<S> getProcessingState​(org.eclipse.microprofile.reactive.messaging.Message<?> message)
      • isPersist

        public static boolean isPersist​(org.eclipse.microprofile.reactive.messaging.Message<?> message)
      • fromMessage

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

        public org.apache.kafka.common.TopicPartition getTopicPartition()
      • getRecordOffset

        public long getRecordOffset()
      • isPersist

        public boolean isPersist()
      • storeLocal

        public T storeLocal​(T state,
                            long offset)
      • storeLocal

        public T storeLocal​(T state)
      • transformAndStoreLocal

        public T transformAndStoreLocal​(T initialState,
                                        Function<T,​T> transformation)
      • storeOnAck

        public T storeOnAck​(T state,
                            long offset)
      • storeOnAck

        public T storeOnAck​(T state)
      • transformAndStoreOnAck

        public T transformAndStoreOnAck​(T initialState,
                                        Function<T,​T> transformation)