T
- The type of data used by this EventEntryStore.public class DefaultEventEntryStore<T> extends Object implements EventEntryStore<T>
SerializedMetaData.isSerializedMetaData(org.axonframework.serializer.SerializedObject)
Constructor and Description |
---|
DefaultEventEntryStore()
Initialize the Event Entry Store, storing timestamps in the system timezone and storing serialized data as byte
arrays.
|
DefaultEventEntryStore(boolean forceUtcTimestamp)
Initializes the EventEntryStore, storing serialized data as byte arrays, with the possibility to force
timestamps to be stored in UTC timezone.
|
DefaultEventEntryStore(EventEntryFactory<T> eventEntryFactory)
Initializes the EventEntryStore, using the given
eventEntryFactory to provide instances of the
JPA entities to use for persistence. |
Modifier and Type | Method and Description |
---|---|
protected Object |
createDomainEventEntry(String aggregateType,
DomainEventMessage event,
SerializedObject<T> serializedPayload,
SerializedObject<T> serializedMetaData)
Allows for customization of the DomainEventEntry to store.
|
protected Object |
createSnapshotEventEntry(String aggregateType,
DomainEventMessage snapshotEvent,
SerializedObject<T> serializedPayload,
SerializedObject<T> serializedMetaData)
Allows for customization of the SnapshotEventEntry to store.
|
protected String |
domainEventEntryEntityName()
The name of the DomainEventEntry entity to use when querying for domain events.
|
Iterator<SerializedDomainEventData<T>> |
fetchAggregateStream(String aggregateType,
Object identifier,
long firstSequenceNumber,
int batchSize,
javax.persistence.EntityManager entityManager)
Creates an iterator that iterates through the events for an aggregate of given
type and given
identifier starting at given firstSequenceNumber . |
Iterator<SerializedDomainEventData<T>> |
fetchFiltered(String whereClause,
Map<String,Object> parameters,
int batchSize,
javax.persistence.EntityManager entityManager)
Creates an iterator that iterates through the Events that conform to the given JPA
whereClause . |
Class<T> |
getDataType()
Returns the type used to store serialized payloads.
|
SimpleSerializedDomainEventData |
loadLastSnapshotEvent(String aggregateType,
Object identifier,
javax.persistence.EntityManager entityManager)
Load the last known snapshot event for aggregate of given
type with given identifier
using given entityManager . |
void |
persistEvent(String aggregateType,
DomainEventMessage event,
SerializedObject<T> serializedPayload,
SerializedObject<T> serializedMetaData,
javax.persistence.EntityManager entityManager)
Persists the given
event which has been serialized into serializedEvent in the
backing data store using given entityManager . |
void |
persistSnapshot(String aggregateType,
DomainEventMessage snapshotEvent,
SerializedObject<T> serializedPayload,
SerializedObject<T> serializedMetaData,
javax.persistence.EntityManager entityManager)
Persists the given
event which has been serialized into serializedEvent in the
backing data store using given entityManager . |
void |
pruneSnapshots(String type,
DomainEventMessage mostRecentSnapshotEvent,
int maxSnapshotsArchived,
javax.persistence.EntityManager entityManager)
Removes old snapshots from the storage for an aggregate of given
type that generated the given
mostRecentSnapshotEvent . |
protected String |
snapshotEventEntryEntityName()
The name of the SnapshotEventEntry entity to use when querying for snapshot events.
|
public DefaultEventEntryStore()
DefaultEventEntryStore(boolean)
public DefaultEventEntryStore(boolean forceUtcTimestamp)
true
, it defaults to false
, for backwards compatibility reasons.
Providing false
will store the timestamps in the system timezone.forceUtcTimestamp
- whether to store dates in UTC format.public DefaultEventEntryStore(EventEntryFactory<T> eventEntryFactory)
eventEntryFactory
to provide instances of the
JPA entities to use for persistence.eventEntryFactory
- the factory providing the Entity instances to persistpublic void persistEvent(String aggregateType, DomainEventMessage event, SerializedObject<T> serializedPayload, SerializedObject<T> serializedMetaData, javax.persistence.EntityManager entityManager)
EventEntryStore
event
which has been serialized into serializedEvent
in the
backing data store using given entityManager
.
These events should be returned by the fetchAggregateStream(...)
methods.persistEvent
in interface EventEntryStore<T>
aggregateType
- The type identifier of the aggregate that generated the eventevent
- The actual event instance. May be used to extract relevant meta dataserializedPayload
- The serialized payload of the eventserializedMetaData
- The serialized MetaData of the evententityManager
- The entity manager providing access to the data storepublic SimpleSerializedDomainEventData loadLastSnapshotEvent(String aggregateType, Object identifier, javax.persistence.EntityManager entityManager)
EventEntryStore
type
with given identifier
using given entityManager
.loadLastSnapshotEvent
in interface EventEntryStore<T>
aggregateType
- The type identifier of the aggregate that generated the eventidentifier
- The identifier of the aggregate to load the snapshot forentityManager
- The entity manager providing access to the data storepublic Iterator<SerializedDomainEventData<T>> fetchFiltered(String whereClause, Map<String,Object> parameters, int batchSize, javax.persistence.EntityManager entityManager)
EventEntryStore
whereClause
.
When the implementation uses batched fetching, it should use given batchSize
. The given
parameters
provide the values for the placeholders used in the where clause.
The "WHERE" keyword must not be included in the whereClause
. If the clause is null or an empty
String, no filters are applied, and an iterator is returned that scans all events in the event store.
The iterator should return events in the order they were added to the event store. In either case, it must
ensure that events originating from the same aggregate are always returned with the lowest sequence number
first.fetchFiltered
in interface EventEntryStore<T>
whereClause
- The JPA clause to be included after the WHERE keywordparameters
- A map containing all the parameter values for parameter keys included in the where clausebatchSize
- The total number of events to return in this batchentityManager
- The entity manager providing access to the data storepublic void persistSnapshot(String aggregateType, DomainEventMessage snapshotEvent, SerializedObject<T> serializedPayload, SerializedObject<T> serializedMetaData, javax.persistence.EntityManager entityManager)
EventEntryStore
event
which has been serialized into serializedEvent
in the
backing data store using given entityManager
.
These snapshot events should be returned by the loadLastSnapshotEvent(...)
methods.persistSnapshot
in interface EventEntryStore<T>
aggregateType
- The type identifier of the aggregate that generated the eventsnapshotEvent
- The actual snapshot event instance. May be used to extract relevant meta dataserializedPayload
- The serialized payload of the eventserializedMetaData
- The serialized MetaData of the evententityManager
- The entity manager providing access to the data storepublic Class<T> getDataType()
EventEntryStore
getDataType
in interface EventEntryStore<T>
protected Object createDomainEventEntry(String aggregateType, DomainEventMessage event, SerializedObject<T> serializedPayload, SerializedObject<T> serializedMetaData)
domainEventEntryEntityName()
method is overridden to
return the correct entity name. Note that it is preferable to provide a custom EventEntryFactory
, instead of overriding these methods.aggregateType
- The type identifier of the aggregateevent
- The event to be storedserializedPayload
- The serialized payload of the eventserializedMetaData
- The serialized meta data of the eventdomainEventEntryEntityName()
,
EventEntryFactory.createDomainEventEntry(String,
org.axonframework.domain.DomainEventMessage, org.axonframework.serializer.SerializedObject,
org.axonframework.serializer.SerializedObject)
protected Object createSnapshotEventEntry(String aggregateType, DomainEventMessage snapshotEvent, SerializedObject<T> serializedPayload, SerializedObject<T> serializedMetaData)
snapshotEventEntryEntityName()
method is overridden to
return the correct entity name. Note that it is preferable to provide a custom EventEntryFactory
, instead of overriding these methods.aggregateType
- The type identifier of the aggregatesnapshotEvent
- The snapshot event to be storedserializedPayload
- The serialized payload of the eventserializedMetaData
- The serialized meta data of the eventsnapshotEventEntryEntityName()
,
EventEntryFactory.createSnapshotEventEntry(String,
org.axonframework.domain.DomainEventMessage, org.axonframework.serializer.SerializedObject,
org.axonframework.serializer.SerializedObject)
protected String domainEventEntryEntityName()
createDomainEventEntry(String, org.axonframework.domain.DomainEventMessage,
org.axonframework.serializer.SerializedObject, org.axonframework.serializer.SerializedObject)
,
EventEntryFactory.getDomainEventEntryEntityName()
protected String snapshotEventEntryEntityName()
createSnapshotEventEntry(String, org.axonframework.domain.DomainEventMessage,
org.axonframework.serializer.SerializedObject, org.axonframework.serializer.SerializedObject)
,
EventEntryFactory.getSnapshotEventEntryEntityName()
public void pruneSnapshots(String type, DomainEventMessage mostRecentSnapshotEvent, int maxSnapshotsArchived, javax.persistence.EntityManager entityManager)
EventEntryStore
type
that generated the given
mostRecentSnapshotEvent
. A number of maxSnapshotsArchived
is expected to remain in the
archive after pruning, unless that number of snapshots has not been created yet. The given
entityManager
provides access to the data store.pruneSnapshots
in interface EventEntryStore<T>
type
- the type of the aggregate for which to prune snapshotsmostRecentSnapshotEvent
- the last appended snapshot eventmaxSnapshotsArchived
- the number of snapshots that may remain archivedentityManager
- the entityManager providing access to the data storepublic Iterator<SerializedDomainEventData<T>> fetchAggregateStream(String aggregateType, Object identifier, long firstSequenceNumber, int batchSize, javax.persistence.EntityManager entityManager)
EventEntryStore
type
and given
identifier
starting at given firstSequenceNumber
. When using batched fetching, the
given batchSize
should be used. The given entityManager
provides access to the backing
data store.
Note that the result is expected to be ordered by sequence number, with the lowest number first.fetchAggregateStream
in interface EventEntryStore<T>
aggregateType
- The type identifier of the aggregate that generated the eventidentifier
- The identifier of the aggregate to load the snapshot forfirstSequenceNumber
- The sequence number of the first event to include in the batchbatchSize
- The number of entries to include in the batch (if available)entityManager
- The entity manager providing access to the data storeCopyright © 2010-2014. All Rights Reserved.