P - the type of the Message payloadS - the type of the StateRepository entriespublic class StatefulMessageConsumer<P,S> extends java.lang.Object implements MessageConsumer<P>
MessageConsumer that is updating a StateRepository.| Constructor and 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.
|
| Modifier and Type | Method and 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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitofpublic StatefulMessageConsumer(java.lang.String keyPattern,
java.lang.Class<P> payloadType,
StateRepository<S> stateRepository,
java.util.function.Function<Message<P>,S> payloadToStateMapper)
The message's Key.partitionKey() is used as the key for repository entries.
keyPattern - the of-pattern of message keys accepted by this consumer.payloadType - the payload type of the messages accepted by this consumerstateRepository - the StateRepository that is holding the StatepayloadToStateMapper - the mapper function used to map message payload to state entitiespublic 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)
The message's Key.partitionKey() is used as the key for repository entries.
keyPattern - the of-pattern of message keys accepted by this consumer.payloadType - the payload type of the messages accepted by this consumerstateRepository - the StateRepository that is holding the StatepayloadToStateMapper - the mapper function used to map message payload to state entitiespublic 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)
keyPattern - the of-pattern of message keys accepted by this consumer.payloadType - the payload type of the messages accepted by this consumerstateRepository - the StateRepository that is holding the StatepayloadToStateMapper - the mapper function used to map message payload to state entitieskeyMapper - the mapper function used to map message keys to StateRepository keys.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)
keyPattern - the of-pattern of message keys accepted by this consumer.payloadType - the payload type of the messages accepted by this consumerstateRepository - the StateRepository that is holding the StatepayloadToStateMapper - the mapper function used to map previous state entity and message payload to state entitieskeyMapper - the mapper function used to map message keys to StateRepository keys.@Nonnull public java.lang.Class<P> payloadType()
events consumed by this EventConsumer.payloadType in interface MessageConsumer<P>@Nonnull public java.util.regex.Pattern keyPattern()
message keys accepted by this consumer.keyPattern in interface MessageConsumer<P>