Class StatefulMessageConsumer<P,​S>

    • Constructor Summary

      Constructors 
      Constructor Description
      StatefulMessageConsumer​(java.lang.String keyPattern, java.lang.Class<P> payloadType, StateRepository<S> stateRepository, java.util.function.BiFunction<java.util.Optional<S>,​? super Message<P>,​S> payloadToStateMapper, java.util.function.Function<? super Message<P>,​java.lang.String> keyMapper)
      Creates a StatefulMessageConsumer.
      StatefulMessageConsumer​(java.lang.String keyPattern, java.lang.Class<P> payloadType, StateRepository<S> stateRepository, java.util.function.BiFunction<java.util.Optional<S>,​Message<P>,​S> payloadToStateMapper)
      Creates a StatefulMessageConsumer.
      StatefulMessageConsumer​(java.lang.String keyPattern, java.lang.Class<P> payloadType, StateRepository<S> stateRepository, java.util.function.Function<? super Message<P>,​S> payloadToStateMapper, java.util.function.Function<? super Message<P>,​java.lang.String> keyMapper)
      Creates a StatefulMessageConsumer.
      StatefulMessageConsumer​(java.lang.String keyPattern, java.lang.Class<P> payloadType, StateRepository<S> stateRepository, java.util.function.Function<Message<P>,​S> payloadToStateMapper)
      Creates a StatefulMessageConsumer.
    • Method Summary

      Modifier and Type Method Description
      void accept​(Message<P> message)  
      java.util.regex.Pattern keyPattern()
      Returns the pattern of message keys accepted by this consumer.
      java.lang.Class<P> payloadType()
      Returns the expected payload type of events consumed by this EventConsumer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.function.Consumer

        andThen
    • Constructor Detail

      • StatefulMessageConsumer

        public StatefulMessageConsumer​(java.lang.String keyPattern,
                                       java.lang.Class<P> payloadType,
                                       StateRepository<S> stateRepository,
                                       java.util.function.Function<Message<P>,​S> payloadToStateMapper)
        Creates a StatefulMessageConsumer.

        The message's Key.partitionKey() is used as the key for repository entries.

        Parameters:
        keyPattern - the of-pattern of message keys accepted by this consumer.
        payloadType - the payload type of the messages accepted by this consumer
        stateRepository - the StateRepository that is holding the State
        payloadToStateMapper - the mapper function used to map message payload to state entities
      • StatefulMessageConsumer

        public StatefulMessageConsumer​(java.lang.String keyPattern,
                                       java.lang.Class<P> payloadType,
                                       StateRepository<S> stateRepository,
                                       java.util.function.BiFunction<java.util.Optional<S>,​Message<P>,​S> payloadToStateMapper)
        Creates a StatefulMessageConsumer.

        The message's Key.partitionKey() is used as the key for repository entries.

        Parameters:
        keyPattern - the of-pattern of message keys accepted by this consumer.
        payloadType - the payload type of the messages accepted by this consumer
        stateRepository - the StateRepository that is holding the State
        payloadToStateMapper - the mapper function used to map message payload to state entities
      • StatefulMessageConsumer

        public StatefulMessageConsumer​(java.lang.String keyPattern,
                                       java.lang.Class<P> payloadType,
                                       StateRepository<S> stateRepository,
                                       java.util.function.Function<? super Message<P>,​S> payloadToStateMapper,
                                       java.util.function.Function<? super Message<P>,​java.lang.String> keyMapper)
        Creates a StatefulMessageConsumer.
        Parameters:
        keyPattern - the of-pattern of message keys accepted by this consumer.
        payloadType - the payload type of the messages accepted by this consumer
        stateRepository - the StateRepository that is holding the State
        payloadToStateMapper - the mapper function used to map message payload to state entities
        keyMapper - the mapper function used to map message keys to StateRepository keys.
      • StatefulMessageConsumer

        public StatefulMessageConsumer​(java.lang.String keyPattern,
                                       java.lang.Class<P> payloadType,
                                       StateRepository<S> stateRepository,
                                       java.util.function.BiFunction<java.util.Optional<S>,​? super Message<P>,​S> payloadToStateMapper,
                                       java.util.function.Function<? super Message<P>,​java.lang.String> keyMapper)
        Creates a StatefulMessageConsumer.
        Parameters:
        keyPattern - the of-pattern of message keys accepted by this consumer.
        payloadType - the payload type of the messages accepted by this consumer
        stateRepository - the StateRepository that is holding the State
        payloadToStateMapper - the mapper function used to map previous state entity and message payload to state entities
        keyMapper - the mapper function used to map message keys to StateRepository keys.
    • Method Detail

      • payloadType

        @Nonnull
        public java.lang.Class<P> payloadType()
        Returns the expected payload type of events consumed by this EventConsumer.
        Specified by:
        payloadType in interface MessageConsumer<P>
        Returns:
        payload type
      • keyPattern

        @Nonnull
        public java.util.regex.Pattern keyPattern()
        Returns the pattern of message keys accepted by this consumer.
        Specified by:
        keyPattern in interface MessageConsumer<P>
        Returns:
        Pattern
      • accept

        public void accept​(Message<P> message)
        Specified by:
        accept in interface java.util.function.Consumer<P>