- Notifications
You must be signed in to change notification settings - Fork22
kurrent-io/KurrentDB-Client-Java
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation

KurrentDB is the event-native database, where business events are immutably stored and streamed. Designed for event-sourced, event-driven, and microservices architectures.
This repository contains anKurrentDB Client SDK written in Java for use with languages on the JVM. It iscompatible with Java 8 and above.
Note: This client is currently under active development and further API changes are expected. Feedback is very welcome.
- General documentation can be found inKurrentDB GRPC Docs.
Kurrent, Inc publishes GA (general availability) versions toMaven Central.
Snapshot versions are pushed on Sonatype Snapshots Repository every time a pull request is merged in the main branchtrunk
.The snippet below shows how to use the Sonatype Snapshots Repository using the Gradle build tool.
repositories {... maven { url uri('https://oss.sonatype.org/content/repositories/snapshots') }...}
The SDK is built usingGradle
. Integration tests run against a server using Docker.
Tests are written usingTestContainers and requireDocker to be installed.
Specific docker images can be specified via the environment variableEVENTSTORE_IMAGE
.
Tracing is the only telemetry currently exported, specifically for theAppend
andSubscribe
(Catchup and Persistent) operations.
For more information about Open Telemetry, refer to theofficial documentation.
This client is compatible with version20.6.1
upwards.
Server setup instructions can be found in thedocs, follow the docker setup for the simplest configuration.
The following snippet showcases a simple example where we form a connection, then write and read events from the server.
Note: If testing locally using--insecure
the url should bekurrentdb://localhost:2113?tls=false
.
classAccountCreated {privateUUIDid;privateStringlogin;publicUUIDgetId() {returnid; }publicStringgetLogin() {returnlogin; }publicvoidsetId(UUIDid) {this.id =id; }publicvoidsetLogin(Stringlogin) {this.login =login; }}
importio.kurrent.dbclient.KurrentDBClient;importio.kurrent.dbclient.KurrentDBClientSettings;importio.kurrent.dbclient.KurrentDBConnectionString;importio.kurrent.dbclient.EventData;importio.kurrent.dbclient.ReadStreamOptions;importio.kurrent.dbclient.ResolvedEvent;importio.kurrent.dbclient.WriteResult;importio.kurrent.dbclient.ReadResult;publicclassMain {publicstaticvoidmain(Stringargs[]) {KurrentDBClientSettingssetts =KurrentDBConnectionString.parseOrThrow("kurrentdb://localhost:2113");KurrentDBClientclient =KurrentDBClient.create(setts);AccountCreatedcreatedEvent =newAccountCreated();createdEvent.setId(UUID.randomUUID());createdEvent.setLogin("ouros");EventDataevent =EventData .builderAsJson("account-created",createdEvent) .build();WriteResultwriteResult =client .appendToStream("accounts",event) .get();ReadStreamOptionsreadStreamOptions =ReadStreamOptions.get() .fromStart() .notResolveLinkTos();ReadResultreadResult =client .readStream("accounts",1,readStreamOptions) .get();ResolvedEventresolvedEvent =readResult .getEvents() .get(0);AccountCreatedwrittenEvent =resolvedEvent.getOriginalEvent() .getEventDataAs(AccountCreated.class);// Doing something productive... }}
This client currently supports creating and getting the result of a continuous projection.
Create a projection:
KurrentDBClientSettingssetts =KurrentDBConnectionString.parseOrThrow("kurrentdb://localhost:2113");KurrentDBProjectionManagementClientclient =KurrentDBProjectionManagementClient.create(setts);client .createContinuous(PROJECTION_NAME,PROJECTION_JS) .get();
Define a class in which to deserialize the result:
publicclassCountResult {privateintcount;publicintgetCount() {returncount; }publicvoidsetCount(finalintcount) {this.count =count; }}
Get the result:
CountResultresult =client .getResult(PROJECTION_NAME,CountResult.class) .get();
For further details please seethe projection management tests.
Information on support can be found on our website:Kurrent Support
Documentation for KurrentDB can be found in thedocs.
Bear in mind that this client is not yet properly documented. We are working hard on a new version of the documentation.
If you find a vulnerability in our software, please contact us. You can find how to reach out us and report it athttps://www.kurrent.io/security#securityThank you very much for supporting our software.
All contributions to the SDK are made via GitHub Pull Requests, and must be licensed under the Apache 2.0 license. Pleasereview ourContributing Guide andCode of Conduct for more information.
About
KurrentDB Java Client
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.