From 04187a1706ffc958a81018d1be6c7df8b6a22965 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Tue, 1 Aug 2023 16:09:33 +0200 Subject: [PATCH] GH-243 - Add section on how to customize the Clock instance to be used to determine event publication dates. --- src/docs/asciidoc/40-events.adoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/docs/asciidoc/40-events.adoc b/src/docs/asciidoc/40-events.adoc index 57d577dd..769a85d3 100644 --- a/src/docs/asciidoc/40-events.adoc +++ b/src/docs/asciidoc/40-events.adoc @@ -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