Class AxonServerEventStore
- All Implemented Interfaces:
DomainEventSequenceAware,EventBus,EventStore,MessageDispatchInterceptorSupport<EventMessage<?>>,StreamableMessageSource<TrackedEventMessage<?>>,SubscribableMessageSource<EventMessage<?>>
- Since:
- 4.0
- Author:
- Zoltan Altfatter, Marc Gathier, Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aAxonServerEventStore. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aAxonServerEventStorebased on the fields contained in theAxonServerEventStore.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic AxonServerEventStore.Builderbuilder()Instantiate a Builder to be able to create aAxonServerEventStore.Creates aStreamableMessageSourcethat streams events from the givencontext, rather than the default context the application was configured to connect to.protected Optional<DomainEventMessage<?>> handleSnapshotReadingError(String aggregateIdentifier, Throwable e) Invoked when an error (ExceptionorLinkageError) occurs while attempting to read a snapshot event.openStream(TrackingToken trackingToken) Open a stream containing all messages since given tracking token.readEvents(String aggregateIdentifier) Open an event stream containing all domain events belonging to the givenaggregateIdentifier.protected org.axonframework.axonserver.connector.event.axon.AxonServerEventStore.AxonIQEventStorageEngineReturns theEventStorageEngineused by the event store.Methods inherited from class org.axonframework.eventsourcing.eventstore.AbstractEventStore
createHeadToken, createTailToken, createTokenAt, lastSequenceNumberFor, prepareCommit, readEvents, stagedDomainEventMessages, storeSnapshotMethods inherited from class org.axonframework.eventhandling.AbstractEventBus
afterCommit, commit, intercept, publish, queuedMessages, registerDispatchInterceptor, subscribeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.MessageDispatchInterceptorSupport
registerDispatchInterceptorMethods inherited from interface org.axonframework.messaging.StreamableMessageSource
createTokenSinceMethods inherited from interface org.axonframework.messaging.SubscribableMessageSource
subscribe
-
Constructor Details
-
AxonServerEventStore
Instantiate aAxonServerEventStorebased on the fields contained in theAxonServerEventStore.Builder.Will assert that the
EventStorageEngineis set. If not, theAxonServerConfigurationandAxonServerConnectionManagershould minimally be provided to create an AxonServer specific EventStorageEngine implementation. If either of thesenullassertions fail, anAxonConfigurationExceptionwill be thrown.- Parameters:
builder- theAxonServerEventStore.Builderused to instantiate aAxonServerEventStoreinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aAxonServerEventStore.The main goal of this Builder is to instantiate an AxonServer specific
EventStorageEngine. The properties which may be provided through this Builder are thus all used to end up with that EventStorageEngine implementation. An EventStorageEngine may be provided directly however, although we encourage the usage of theAxonServerEventStore.Builder.configurationandAxonServerEventStore.Builder.axonServerConnectionManagerfunctions to let it be created.The
EventUpcasteris defaulted to aNoOpEventUpcasterand theEventBusSpanFactoryis defaulted to aDefaultEventBusSpanFactorybacked by aNoOpSpanFactory.The event and snapshot
Serializer,AxonServerConfigurationandAxonServerConnectionManagerare hard requirements if no EventStorageEngine is provided directly.- Returns:
- a Builder to be able to create a
AxonServerEventStore
-
openStream
Description copied from interface:StreamableMessageSourceOpen a stream containing all messages since given tracking token. Pass atrackingTokenofnullto open a stream containing all available messages. Note that the returned stream is infinite, so beware of applying terminal operations to the returned stream.- Parameters:
trackingToken- object containing the position in the stream ornullto open a stream containing all messages- Returns:
- a stream of messages since the given trackingToken
-
query
-
storageEngine
protected org.axonframework.axonserver.connector.event.axon.AxonServerEventStore.AxonIQEventStorageEngine storageEngine()Description copied from class:AbstractEventStoreReturns theEventStorageEngineused by the event store.- Overrides:
storageEnginein classAbstractEventStore- Returns:
- The event storage engine used by this event store
-
createStreamableMessageSourceForContext
public StreamableMessageSource<TrackedEventMessage<?>> createStreamableMessageSourceForContext(String context) Creates aStreamableMessageSourcethat streams events from the givencontext, rather than the default context the application was configured to connect to.- Parameters:
context- the name of the context to create a message source for- Returns:
- a
StreamableMessageSourceofTrackedEventMessages tied to the givencontext
-
handleSnapshotReadingError
protected Optional<DomainEventMessage<?>> handleSnapshotReadingError(String aggregateIdentifier, Throwable e) Description copied from class:AbstractEventStoreInvoked when an error (ExceptionorLinkageError) occurs while attempting to read a snapshot event. This method can be overridden to change the default behavior, which is to log the exception (warn level) and ignore the snapshot.Overriding implementations may choose to return normally, or raise an exception. Exceptions raised from this method are propagated to the caller of the
AbstractEventStore.readEvents(String)orAbstractEventStore.readEvents(String, long)methods.Returning an empty Optional will force the initialization of the aggregate to happen based on the entire event stream of that aggregate.
- Overrides:
handleSnapshotReadingErrorin classAbstractEventStore- Parameters:
aggregateIdentifier- The identifier of the aggregate for which an snapshot failed to loade- The exception or error that occurred while loading or deserializing the snapshot- Returns:
- An optional DomainEventMessage to use as the snapshot for this aggregate
-
readEvents
Description copied from class:AbstractEventStoreOpen an event stream containing all domain events belonging to the givenaggregateIdentifier.The returned stream is finite, ending with the last known event of the aggregate. If the event store holds no events of the given aggregate an empty stream is returned.
This implementation returns a
DomainEventStreamstarting with the last stored snapshot of the aggregate followed by subsequent domain events.- Specified by:
readEventsin interfaceEventStore- Overrides:
readEventsin classAbstractEventStore- Parameters:
aggregateIdentifier- the identifier of the aggregate whose events to fetch- Returns:
- a stream of all currently stored events of the aggregate
-