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,

@Singleton
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 "io.eventuate.local.java:eventuate-local-java-micronaut-jdbc:${eventuateLocalVersion}"
}
  • EmbeddedTestAggregateStoreFactory - used for embedded test Event Store. This is useful for tests:
dependencies {
  testCompile "io.eventuate.client.java:eventuate-client-java-micronaut-jdbc:$eventuateClientVersion"
}

Externalized configuration for the Event Store Client

The Eventuate Client uses the Micronaut configuration mechanism.

You must specify the following properties:

datasources:
  default:
    url: ${DATASOURCE_URL}
    driverClassName: ${DATASOURCE_DRIVERCLASSNAME}
    username: ${DATASOURCE_USERNAME}
    password: ${DATASOURCE_PASSWORD}

eventuatelocal:
  kafka:
    bootstrap:
      servers: ${DOCKER_HOST_IP}:9092
  zookeeper:
    connection:
      string: ${DOCKER_HOST_IP}:2181

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