public class AxonServerEventStore extends AbstractEventStore
Modifier and Type | Class and Description |
---|---|
static class |
AxonServerEventStore.Builder
Builder class to instantiate a
AxonServerEventStore . |
Modifier | Constructor and Description |
---|---|
protected |
AxonServerEventStore(AxonServerEventStore.Builder builder)
Instantiate a
AxonServerEventStore based on the fields contained in the AxonServerEventStore.Builder . |
Modifier and Type | Method and Description |
---|---|
static AxonServerEventStore.Builder |
builder()
Instantiate a Builder to be able to create a
AxonServerEventStore . |
StreamableMessageSource<TrackedEventMessage<?>> |
createStreamableMessageSourceForContext(String context)
Creates a
StreamableMessageSource that streams events from the given context , rather than the
default context the application was configured to connect to. |
protected Optional<DomainEventMessage<?>> |
handleSnapshotReadingError(String aggregateIdentifier,
Throwable e)
Invoked when an error (
Exception or LinkageError ) occurs while attempting to read a snapshot
event. |
TrackingEventStream |
openStream(TrackingToken trackingToken)
Open a stream containing all messages since given tracking token.
|
QueryResultStream |
query(String query,
boolean liveUpdates) |
DomainEventStream |
readEvents(String aggregateIdentifier)
Open an event stream containing all domain events belonging to the given
aggregateIdentifier . |
protected org.axonframework.axonserver.connector.event.axon.AxonServerEventStore.AxonIQEventStorageEngine |
storageEngine()
Returns the
EventStorageEngine used by the event store. |
createHeadToken, createTailToken, createTokenAt, lastSequenceNumberFor, prepareCommit, readEvents, stagedDomainEventMessages, storeSnapshot
afterCommit, commit, intercept, publish, queuedMessages, registerDispatchInterceptor, subscribe
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
subscribe
registerDispatchInterceptor
createTokenSince
protected AxonServerEventStore(AxonServerEventStore.Builder builder)
AxonServerEventStore
based on the fields contained in the AxonServerEventStore.Builder
.
Will assert that the EventStorageEngine
is set. If not, the AxonServerConfiguration
and AxonServerConnectionManager
should minimally be provided to create an AxonServer specific EventStorageEngine
implementation. If either of these null
assertions fail, an AxonConfigurationException
will be
thrown.
builder
- the AxonServerEventStore.Builder
used to instantiate a AxonServerEventStore
instancepublic static AxonServerEventStore.Builder builder()
AxonServerEventStore
.
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 the
AxonServerEventStore.Builder.configuration
and AxonServerEventStore.Builder.axonServerConnectionManager
functions to let it be created.
The EventUpcaster
is defaulted to a NoOpEventUpcaster
and the EventBusSpanFactory
is
defaulted to a DefaultEventBusSpanFactory
backed by a
NoOpSpanFactory
.
The event and snapshot Serializer
, AxonServerConfiguration
and
AxonServerConnectionManager
are hard requirements if no EventStorageEngine is provided directly.
AxonServerEventStore
public TrackingEventStream openStream(TrackingToken trackingToken)
StreamableMessageSource
trackingToken
of null
to
open a stream containing all available messages. Note that the returned stream is infinite, so beware of
applying terminal operations to the returned stream.trackingToken
- object containing the position in the stream or null
to open a stream containing all
messagespublic QueryResultStream query(String query, boolean liveUpdates)
protected org.axonframework.axonserver.connector.event.axon.AxonServerEventStore.AxonIQEventStorageEngine storageEngine()
AbstractEventStore
EventStorageEngine
used by the event store.storageEngine
in class AbstractEventStore
public StreamableMessageSource<TrackedEventMessage<?>> createStreamableMessageSourceForContext(String context)
StreamableMessageSource
that streams events from the given context
, rather than the
default context the application was configured to connect to.context
- the name of the context to create a message source forStreamableMessageSource
of TrackedEventMessage
s tied to the given context
protected Optional<DomainEventMessage<?>> handleSnapshotReadingError(String aggregateIdentifier, Throwable e)
AbstractEventStore
Exception
or LinkageError
) 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)
or AbstractEventStore.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.
handleSnapshotReadingError
in class AbstractEventStore
aggregateIdentifier
- The identifier of the aggregate for which an snapshot failed to loade
- The exception or error that occurred while loading or deserializing the snapshotpublic DomainEventStream readEvents(String aggregateIdentifier)
AbstractEventStore
aggregateIdentifier
.
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 DomainEventStream
starting with the last stored snapshot of the aggregate
followed by subsequent domain events.
readEvents
in interface EventStore
readEvents
in class AbstractEventStore
aggregateIdentifier
- the identifier of the aggregate whose events to fetchCopyright © 2010–2024. All rights reserved.