Configuring the Micronaut application context

Once you have written your services and event handlers you must configure the Micronaut application context to instantiate them and wire them together.

Define Micronaut beans for your services and event handlers

You must define Micronaut beans for your services and event handlers. You can either do this using @Singleton inside a factory or on a bean class itself.

Define Micronaut Beans for your snapshot strategies

If you are using snapshot strategies they must be defined as Micronaut Beans. For example,

public AccountSnapshotStrategy accountSnapshotStrategy() {
  return new AccountSnapshotStrategy();

Choosing the Event Store implementation

You must have in your classpath a @Factory class for an event store client implementation. There are the following options:

  • EventuateLocalFactory - used for Eventuate Local client:
dependencies {
  compile "${eventuateLocalVersion}"
  • EmbeddedTestAggregateStoreFactory - used for embedded test Event Store. This is useful for tests:
dependencies {
  testCompile "$eventuateClientVersion"

Externalized configuration for the Event Store Client

The Eventuate Client uses the Micronaut configuration mechanism.

You must specify the following properties:

    url: ${DATASOURCE_URL}
    username: ${DATASOURCE_USERNAME}
    password: ${DATASOURCE_PASSWORD}

      servers: ${DOCKER_HOST_IP}:9092
      string: ${DOCKER_HOST_IP}:2181

Stay in touch
Copyright © 2021 Eventuate, Inc • All rights reserved.