Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
138 lines (80 sloc) 5.23 KB
outputFileName
index.html

Step 1 - Install, run, and write your first event

[!include]

This first step covers installation and running Event Store, and writing your first event.

[!include]

Interacting with an Event Store server

There are three ways to interact with Event Store:

  1. With the Admin UI.
  2. With the HTTP API.
  3. With a Client API, which you need to install first. Our documentation covers the .NET Core client API and the JVM client but others are available.

.NET client

Install the .NET client API using your preferred method.

Add it to your project:

dotnet add package EventStore.Client

And require it in your code:

using EventStore.ClientAPI;

JVM client

Add the JVM client using Maven:

<dependency>
    <groupId>com.geteventstore</groupId>
    <artifactId>eventstore-client_2.12</artifactId>
    <version>5.0.8</version>
</dependency>

And require it in your code:

import eventstore.*;

Connecting to Event Store

If you want to use the Admin UI or the HTTP API, then you use port 2113. For example, http://127.0.0.1:2113/ in your web browser, or curl -i http://127.0.0.1:2113 for the HTTP API.

[!TIP] The default username and password is admin:changeit

The Admin UI Dashboard

To use a client API, you use port 1113 and create a connection:

.NET client

When using the .NET client, you also need to give the connection a name.

[!code-csharpgetting-started-connection]

[!NEXT] In this example we used the EventStoreConnection.Create() overloaded method but others are available.

JVM client

[!code-javagetting-started-connection]

[!NOTE] For our JVM examples we use akka, a toolkit for building highly concurrent and distributed JVM applications.


Writing events to an Event Stream

Event Store operates on a concept of Event Streams, and the first operation we look at is how to write to a stream. If you are Event Sourcing a domain model, a stream equates to an aggregate function. Event Store can handle hundreds of millions of streams, so create as many as you need.

If you post to a stream that doesn't exist, Event Store creates it before adding the events.

Writing events using the admin UI

You can write events using the Admin UI by clicking the Stream Browser tab, the Add Event button, filling in the form with relevant values and clicking the Add button at the bottom of the page.

Creating an event with the Admin UI interface

Open a text editor, copy and paste the following event definition, and save it as event.json.

[!code-jsongetting-started-write-event-json]

Writing events programmatically

HTTP API

Use the following cURL command, passing the name of the stream and the events to write:

[!code-bashgetting-started-write-event-request]

[!NEXT] Read this guide for more information on how to write events with the HTTP API.

[!NOTE] You can also post events to the HTTP API as XML, by changing the Content-Type header to XML.

.NET API

To use the .NET API, use the following method, passing the name of the stream, the version, and the events to write:

[!code-csharpgetting-started-write-event-request]

[!NEXT] Read this guide for more information on how to write events with the .NET API. We don't cover version checking in this guide, but you can read more in the optimistic concurrency guide.

JVM client

To use the JVM Client, use the following method, passing the name of the stream, the version, and the events to write:

[!code-javagetting-started-connection]


Next step

In this first part of our getting started guide you learned how to install and run Event Store and write your first event. The next part covers reading events from a stream.

You can’t perform that action at this time.