Configuring the Spring application context

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

Define Spring beans for your services and event handlers

You must define Spring beans for your services and event handlers. As always, you can either do this explicitly using @Bean definitions or you can use component scanning.

Enabling the high-level event handler API

If your code uses the high-level event handler API then you must annotate your @Configuration class with @EnableEventHandlers:

class MyConfigurationClass {

Choosing the Event Store implementation

You must @Import into your Spring ApplicationContext an @Configuration class for an event store client implementation. Your production code will use @Import(EventuateHttpStompClientConfiguration.class), which imports the configuration for the Eventuate HTTP/STOMP client and the Eventuate Local edition.

Your test code can also use the Eventuate client. However, you can sometimes simplify tests by using the embedded test Event Store. Configure your test code’s application context by using @Import(EventuateJdbcEventStoreConfiguration.class)

Externalized configuration for the Event Store Client

The Eventuate Client uses the Spring Boot Externalized configuration mechanism. The configuration settings depend on which version of Eventuate you are using.

Eventuate SaaS version

If you are using the Eventuate SaaS version, you must configure the client to talk to the Eventuate server.

You must specify the following properties:

  • eventuate.apiKeyId - API key id (previously eventStore.userId)
  • eventuate.apiKeySecret - API key secret (previously eventStore.password)

You can, for example, set the operating system environment variables, EVENTUATE_API_KEY_ID and EVENTUATE_API_KEY_SECRET.

Eventuate Local edition

You must specify the following properties:

  • spring.datasource.url
  • spring.datasource.username
  • spring.datasource.password
  • eventuatelocal.aggregateStore.bootstrap.servers - Apache Kafka servers, e.g. kafkaserver:9092

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