Class EventStoreDBClient
-
Method Summary
Modifier and TypeMethodDescriptionappendToStream(String streamName, AppendToStreamOptions options, EventData... events) Appends events to a given stream.appendToStream(String streamName, AppendToStreamOptions options, Iterator<EventData> events) Appends events to a given stream.appendToStream(String streamName, EventData... events) Appends events to a given stream.appendToStream(String streamName, Iterator<EventData> events) Appends events to a given stream.static EventStoreDBClientcreate(EventStoreDBClientSettings settings) Creates a gRPC client to EventStoreDB database.deleteStream(String streamName) Deletes a given stream.deleteStream(String streamName, DeleteStreamOptions options) Deletes a given stream.getStreamMetadata(String streamName) Reads stream's metadata.getStreamMetadata(String streamName, ReadStreamOptions options) Reads stream's metadata.readAll()Reads events from the $all stream.readAll(ReadAllOptions options) Reads events from the $all stream.org.reactivestreams.Publisher<ReadMessage>org.reactivestreams.Publisher<ReadMessage>readAllReactive(ReadAllOptions options) Reads events from the $all stream.readStream(String streamName, ReadStreamOptions options) Reads events from a given stream.org.reactivestreams.Publisher<ReadMessage>readStreamReactive(String streamName) Reads events from a given stream.org.reactivestreams.Publisher<ReadMessage>readStreamReactive(String streamName, ReadStreamOptions options) Reads events from a given stream.setStreamMetadata(String streamName, AppendToStreamOptions options, StreamMetadata metadata) Sets a stream's metadata.setStreamMetadata(String streamName, StreamMetadata metadata) Sets a stream's metadata.subscribeToAll(SubscriptionListener listener) Subscriptions allow you to subscribe to $all stream and receive notifications about new events added to the stream.subscribeToAll(SubscriptionListener listener, SubscribeToAllOptions options) Subscriptions allow you to subscribe to $all stream and receive notifications about new events added to the stream.subscribeToStream(String streamName, SubscriptionListener listener) Subscriptions allow you to subscribe to a stream and receive notifications about new events added to the stream.subscribeToStream(String streamName, SubscriptionListener listener, SubscribeToStreamOptions options) Subscriptions allow you to subscribe to a stream and receive notifications about new events added to the stream.tombstoneStream(String streamName) Tombstones a given stream.tombstoneStream(String streamName, DeleteStreamOptions options) Tombstones a given stream.Methods inherited from class com.eventstore.dbclient.EventStoreDBClientBase
getServerVersion, isShutdown, shutdown
-
Method Details
-
create
Creates a gRPC client to EventStoreDB database. -
appendToStream
Appends events to a given stream.- Parameters:
streamName- stream's name.events- events to send.- Returns:
- a write result if successful.
- See Also:
-
appendToStream
Appends events to a given stream.- Parameters:
streamName- stream's name.events- events to send.- Returns:
- a write result if successful.
- See Also:
-
appendToStream
public CompletableFuture<WriteResult> appendToStream(String streamName, AppendToStreamOptions options, EventData... events) Appends events to a given stream.- Parameters:
streamName- stream's name.options- append stream request's options.events- events to send.- Returns:
- a write result if successful.
- See Also:
-
appendToStream
public CompletableFuture<WriteResult> appendToStream(String streamName, AppendToStreamOptions options, Iterator<EventData> events) Appends events to a given stream.- Parameters:
streamName- stream's name.options- append stream request's options.events- events to send.- Returns:
- a write result if successful.
- See Also:
-
setStreamMetadata
Sets a stream's metadata.- Parameters:
streamName- stream's name.metadata- stream's metadata- Returns:
- a write result if successful.
- See Also:
-
setStreamMetadata
public CompletableFuture<WriteResult> setStreamMetadata(String streamName, AppendToStreamOptions options, StreamMetadata metadata) Sets a stream's metadata.- Parameters:
streamName- stream's name.options- append stream request's options.metadata- stream's metadata- Returns:
- a write result if successful.
- See Also:
-
readStream
Reads events from a given stream. The reading can be done forwards and backwards.- Parameters:
streamName- stream's name.options- read request's operations.
-
readStreamReactive
Reads events from a given stream. The reading can be done forwards and backwards.- Parameters:
streamName- stream's name.
-
readStreamReactive
public org.reactivestreams.Publisher<ReadMessage> readStreamReactive(String streamName, ReadStreamOptions options) Reads events from a given stream. The reading can be done forwards and backwards.- Parameters:
streamName- stream's name.options- read request's operations.
-
getStreamMetadata
Reads stream's metadata.- Parameters:
streamName- stream's name.- See Also:
-
getStreamMetadata
public CompletableFuture<StreamMetadata> getStreamMetadata(String streamName, ReadStreamOptions options) Reads stream's metadata.- Parameters:
streamName- stream's name.options- read request's operations.- See Also:
-
readAll
Reads events from the $all stream. The reading can be done forwards and backwards. -
readAll
Reads events from the $all stream. The reading can be done forwards and backwards.- Parameters:
options- options of the read $all request.
-
readAllReactive
-
readAllReactive
Reads events from the $all stream. The reading can be done forwards and backwards.- Parameters:
options- options of the read $all request.
-
subscribeToStream
public CompletableFuture<Subscription> subscribeToStream(String streamName, SubscriptionListener listener) Subscriptions allow you to subscribe to a stream and receive notifications about new events added to the stream. You provide an even handler and an optional starting point to the subscription. The handler is called for each event from the starting point onward. If events already exist, the handler will be called for each event one by one until it reaches the end of the stream. From there, the server will notify the handler whenever a new event appears.- Parameters:
streamName- stream's name.listener- consumes a subscription's events.- Returns:
- a subscription handle.
-
subscribeToStream
public CompletableFuture<Subscription> subscribeToStream(String streamName, SubscriptionListener listener, SubscribeToStreamOptions options) Subscriptions allow you to subscribe to a stream and receive notifications about new events added to the stream. You provide an even handler and an optional starting point to the subscription. The handler is called for each event from the starting point onward. If events already exist, the handler will be called for each event one by one until it reaches the end of the stream. From there, the server will notify the handler whenever a new event appears.- Parameters:
streamName- stream's name.listener- consumes a subscription's events.options- a subscription request's options.- Returns:
- a subscription handle.
-
subscribeToAll
Subscriptions allow you to subscribe to $all stream and receive notifications about new events added to the stream. You provide an even handler and an optional starting point to the subscription. The handler is called for each event from the starting point onward. If events already exist, the handler will be called for each event one by one until it reaches the end of the stream. From there, the server will notify the handler whenever a new event appears.- Parameters:
listener- consumes a subscription's events.- Returns:
- a subscription handle.
-
subscribeToAll
public CompletableFuture<Subscription> subscribeToAll(SubscriptionListener listener, SubscribeToAllOptions options) Subscriptions allow you to subscribe to $all stream and receive notifications about new events added to the stream. You provide an even handler and an optional starting point to the subscription. The handler is called for each event from the starting point onward. If events already exist, the handler will be called for each event one by one until it reaches the end of the stream. From there, the server will notify the handler whenever a new event appears.- Parameters:
listener- consumes a subscription's events.options- subscription to $all request's options.- Returns:
- a subscription handle.
-
deleteStream
Deletes a given stream.Makes use of Truncate before. When a stream is deleted, its Truncate before is set to the stream's current last event number. When a deleted stream is read, the read will return a StreamNotFound error. After deleting the stream, you are able to write to it again, continuing from where it left off.
Note: Deletion is reversible until the scavenging process runs.- Parameters:
streamName- stream's name- Returns:
- if successful, delete result.
- See Also:
-
deleteStream
Deletes a given stream.Makes use of Truncate before, When a stream is deleted, its Truncate before is set to the stream's current last event number. When a soft deleted stream is read, the read will return a StreamNotFound error. After deleting the stream, you are able to write to it again, continuing from where it left off.
Note: soft deletion is reversible until the scavenging process runs.- Parameters:
streamName- stream's nameoptions- delete stream request's options.- Returns:
- if successful, delete result.
- See Also:
-
tombstoneStream
Tombstones a given stream.Writes a tombstone event to the stream, permanently deleting it. The stream cannot be recreated or written to again. Tombstone events are written with the event's type '$streamDeleted'. When a tombstoned stream is read, the read will return a StreamDeleted error.
- Parameters:
streamName- a stream's name.- Returns:
- if successful, delete result.
- See Also:
-
tombstoneStream
public CompletableFuture<DeleteResult> tombstoneStream(String streamName, DeleteStreamOptions options) Tombstones a given stream.Writes a tombstone event to the stream, permanently deleting it. The stream cannot be recreated or written to again. Tombstone events are written with the event's type '$streamDeleted'. When a tombstoned stream is read, the read will return a StreamDeleted error.
- Parameters:
streamName- a stream's name.options- delete stream request's options.- Returns:
- if successful, delete result.
- See Also:
-