|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.eventstore.jdbc.JdbcEventStore
public class JdbcEventStore
An EventStore implementation that uses JPA to store DomainEvents in a database. The actual DomainEvent is stored as a serialized blob of bytes. Other columns are used to store meta-data that allow quick finding of DomainEvents for a specific aggregate in the correct order.
This EventStore supports snapshots pruning, which can enabled by configuring amaximum number of snapshots to archive
. By default snapshot pruning is configured to archive only snapshot per aggregate.
The serializer used to serialize the events is configurable. By default, the XStreamSerializer
is used.
Constructor Summary | |
---|---|
JdbcEventStore(ConnectionProvider connectionProvider)
Initialize a JdbcEventStore using the default EntryStore and an XStreamSerializer , which serializes events as XML. |
|
JdbcEventStore(DataSource dataSource)
Initialize a JdbcEventStore using the given eventEntryStore and an XStreamSerializer , which serializes events as XML. |
|
JdbcEventStore(EventEntryStore eventEntryStore)
Initialize a JdbcEventStore using the given eventEntryStore and an XStreamSerializer , which serializes events as XML. |
|
JdbcEventStore(EventEntryStore eventEntryStore,
Serializer serializer)
Initializes a JdbcEventStore using the given eventEntryStore and serializer . |
Method Summary | |
---|---|
void |
appendEvents(String type,
DomainEventStream events)
Append the events in the given stream to the event store. |
void |
appendSnapshotEvent(String type,
DomainEventMessage snapshotEvent)
Append the given snapshotEvent to the snapshot event log for the given type type . |
CriteriaBuilder |
newCriteriaBuilder()
Returns a CriteriaBuilder that allows the construction of criteria for this EventStore implementation |
DomainEventStream |
readEvents(String type,
Object identifier)
Read the events of the aggregate identified by the given type and identifier that allow the current aggregate state to be rebuilt. |
DomainEventStream |
readEvents(String type,
Object identifier,
long firstSequenceNumber)
Returns a Stream containing events for the aggregate identified by the given type and identifier , starting at the event with the given firstSequenceNumber (included). |
DomainEventStream |
readEvents(String type,
Object identifier,
long firstSequenceNumber,
long lastSequenceNumber)
Returns a Stream containing events for the aggregate identified by the given type and identifier , starting at the event with the given firstSequenceNumber (included) up to and including the
event with given lastSequenceNumber . |
void |
setBatchSize(int batchSize)
Sets the number of events that should be read at each database access. |
void |
setMaxSnapshotsArchived(int maxSnapshotsArchived)
Sets the maximum number of snapshots to archive for an aggregate. |
void |
setPersistenceExceptionResolver(PersistenceExceptionResolver persistenceExceptionResolver)
Sets the persistenceExceptionResolver that will help detect concurrency exceptions from the backing database. |
void |
setUpcasterChain(UpcasterChain upcasterChain)
Sets the UpcasterChain which allow older revisions of serialized objects to be deserialized. |
void |
visitEvents(Criteria criteria,
EventVisitor visitor)
Loads all events available in the event store that match the given criteria and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage) for each event found. |
void |
visitEvents(EventVisitor visitor)
Loads all events available in the event store and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage)
for each event found. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JdbcEventStore(EventEntryStore eventEntryStore, Serializer serializer)
eventEntryStore
and serializer
.
eventEntryStore
- The EventEntryStore that stores individual entries in the underlying data sourceserializer
- The serializer to serialize and deserialize events withpublic JdbcEventStore(EventEntryStore eventEntryStore)
eventEntryStore
and an XStreamSerializer
, which serializes events as XML.
eventEntryStore
- The instance providing persistence logic for Domain Event entriespublic JdbcEventStore(ConnectionProvider connectionProvider)
EntryStore
and an XStreamSerializer
, which serializes events as XML.
The given connectionProvider
is used to obtain connections to the underlying data source
connectionProvider
- The connection provider to obtain connections frompublic JdbcEventStore(DataSource dataSource)
eventEntryStore
and an XStreamSerializer
, which serializes events as XML.
Obtains connection from the given dataSource
, unless a connection was already obtained in the same
Unit of Work, in which case that connection is re-used instead.
dataSource
- The DataSource to obtain connections from, when necessary.Method Detail |
---|
public void appendEvents(String type, DomainEventStream events)
stream
to the event store.
appendEvents
in interface EventStore
type
- The type descriptor of the object to storeevents
- The event stream containing the events to storepublic DomainEventStream readEvents(String type, Object identifier)
readEvents
in interface EventStore
type
- The type descriptor of the object to retrieveidentifier
- The unique aggregate identifier of the events to load
public DomainEventStream readEvents(String type, Object identifier, long firstSequenceNumber)
PartialStreamSupport
type
and identifier
, starting at the event with the given firstSequenceNumber
(included).
The returned stream will not contain any snapshot events.
readEvents
in interface PartialStreamSupport
type
- The type identifier of the aggregateidentifier
- The identifier of the aggregatefirstSequenceNumber
- The sequence number of the first event to find
public DomainEventStream readEvents(String type, Object identifier, long firstSequenceNumber, long lastSequenceNumber)
PartialStreamSupport
type
and identifier
, starting at the event with the given firstSequenceNumber
(included) up to and including the
event with given lastSequenceNumber
.
If no event with given lastSequenceNumber
exists, the returned stream will simply read until the end of
the aggregate's events.
The returned stream will not contain any snapshot events.
readEvents
in interface PartialStreamSupport
type
- The type identifier of the aggregateidentifier
- The identifier of the aggregatefirstSequenceNumber
- The sequence number of the first event to findlastSequenceNumber
- The sequence number of the last event in the stream
public void appendSnapshotEvent(String type, DomainEventMessage snapshotEvent)
snapshotEvent
to the snapshot event log for the given type type
. The
sequence number of the snapshotEvent
must be equal to the sequence number of the last regular
domain
event that is included in the snapshot.
Implementations may choose to prune snapshots upon appending a new snapshot, in order to minimize storage space.
Upon appending a snapshot, this particular EventStore implementation also prunes snapshots which are considered
redundant because they fall outside of the range of maximum snapshots to archive.
appendSnapshotEvent
in interface SnapshotEventStore
type
- The type of aggregate the event belongs tosnapshotEvent
- The event summarizing one or more domain events for a specific aggregate.public void visitEvents(EventVisitor visitor)
EventStoreManagement
EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage)
for each event found. Events of a single aggregate are guaranteed to be ordered by their sequence number.
Implementations are encouraged, though not required, to supply events in the absolute chronological order.
Processing stops when the visitor throws an exception.
visitEvents
in interface EventStoreManagement
visitor
- The visitor the receives each loaded eventpublic void visitEvents(Criteria criteria, EventVisitor visitor)
EventStoreManagement
criteria
and calls EventVisitor.doWithEvent(org.axonframework.domain.DomainEventMessage)
for each event found. Events of a single
aggregate are guaranteed to be ordered by their sequence number.
Implementations are encouraged, though not required, to supply events in the absolute chronological order.
Processing stops when the visitor throws an exception.
visitEvents
in interface EventStoreManagement
criteria
- The criteria describing the events to selectvisitor
- The visitor the receives each loaded eventEventStoreManagement.newCriteriaBuilder()
public CriteriaBuilder newCriteriaBuilder()
EventStoreManagement
newCriteriaBuilder
in interface EventStoreManagement
EventStoreManagement.visitEvents(Criteria, org.axonframework.eventstore.EventVisitor)
public void setPersistenceExceptionResolver(PersistenceExceptionResolver persistenceExceptionResolver)
persistenceExceptionResolver
- the persistenceExceptionResolver that will help detect concurrency
exceptionspublic void setBatchSize(int batchSize)
batchSize
- the number of events to read on each database access. Default to 100.public void setUpcasterChain(UpcasterChain upcasterChain)
UpcasterAware
setUpcasterChain
in interface UpcasterAware
upcasterChain
- the upcaster chain providing the upcasting capabilitiespublic void setMaxSnapshotsArchived(int maxSnapshotsArchived)
maxSnapshotsArchived
- The maximum number of snapshots to archive for an aggregate. A value less than 1
disables pruning of snapshots.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |