GH-243 - Add section on how to customize the Clock instance to be used to determine event publication dates.

This commit is contained in:
Oliver Drotbohm
2023-08-01 16:09:33 +02:00
parent c23c26bd78
commit 04187a1706

View File

@@ -139,6 +139,23 @@ Each log entry contains the original event in serialized form.
The `EventSerializer` abstraction contained in `spring-modulith-events-core` allows plugging different strategies for how to turn the event instances into a format suitable for the datastore.
Spring Modulith provides a Jackson-based JSON implementation through the `spring-modulith-events-jackson` artifact, which registers a `JacksonEventSerializer` consuming an `ObjectMapper` through standard Spring Boot auto-configuration by default.
[[events.customize-publication-date]]
== Customizing the Event Publication Date
By default, the Event Publication Registry will use the date returned by the `Clock.systemUTC()` as event publication date.
If you want to customize this, register a bean of type clock with the application context:
[source, java]
----
@Configuration
class MyConfiguration {
@Bean
Clock myCustomClock() {
return … // Your custom Clock instance created here.
}
}
----
[[events.starters]]
== Spring Boot Event Registry Starters