V - the type of the entities stored in the StateRepositorypublic abstract class JournalingStateRepository<V> extends DelegatingStateRepository<V> implements Journal
StateRepository that is also acting as a Journal.
Using JournalingStateRepository is the easiest way to get a Journal for the entites
that result from applying messages to the application's state.
Using the Journal, it is possible to get a history of messages, that where changing the entities stored
in the StateRepository by calling Journal.getJournalFor(String).
For every instance of JournalingStateRepository, the
JournalingStateRepositoryBeanPostProcessor will find all bean methods annotated with
EventSourceConsumer and register a JournalingInterceptor, so that consumed messages
will be registered in the message store.
The associated message store is required to provide a Index.JOURNAL_KEY index. See Journal
for details.
Example:
public class ProductStateRepository extends JournalingStateRepository<Product> {
public ProductStateRepository(final StateRepository<Product> delegate,
final MessageStore journalMessageStore) {
super(delegate, journalMessageStore);
}
@EventSourceConsumer(
eventSource = "productSource",
payloadType = ProductPayload.class
)
public void consumeBananas(final Message<Payload> message) {
final String entityId = message.getKey().partitionKey();
put(entityIds, message.getPayload();
}
}
| Constructor and Description |
|---|
JournalingStateRepository(StateRepository<V> delegate,
MessageStore messageStore) |
| Modifier and Type | Method and Description |
|---|---|
MessageStore |
getMessageStore()
Returns the
MessageStore used to store the messages of the journaled entities. |
clear, close, compute, consumeAll, get, getName, keySet, put, remove, sizeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetJournalFor, getName, journalKeyOfpublic JournalingStateRepository(StateRepository<V> delegate, MessageStore messageStore)
public MessageStore getMessageStore()
JournalMessageStore used to store the messages of the journaled entities.
The store must be indexed for Index.JOURNAL_KEY. For every given entity, the journal-key
must match the key returned by Journal.journalKeyOf(String)
getMessageStore in interface Journal