spring-modulith
spring-modulith copied to clipboard
Customizing the Event Publication Date, but not working
When I configured a custom Clock class as a bean, the event's publish date was still displayed in UTC timezone. So, I looked for the point where the EventPublication instance was created, and I found it.
The publishDate and completionDate types of EventPublication are Instant. Therefore, if I change the clock bean, the instant will always be set to UTC timezone time.
public class DefaultEventPublicationRegistry implements DisposableBean, EventPublicationRegistry, CompletedEventPublications {
public Collection<TargetEventPublication> store(Object event, Stream<PublicationTargetIdentifier> listeners) {
Stream var10000 = listeners.map((it) -> {
return TargetEventPublication.of(event, it, this.clock.instant()); // makes an Instant instance, and it always uses UTC timezone
}).peek((it) -> {
LOGGER.debug("Registering publication of {} for {}.", it.getEvent().getClass().getName(), it.getTargetIdentifier().getValue());
});
...
}
}
How can I customize the event publication date?
The publishDate and completionDate types of EventPublication are Instant. Therefore, if I change the clock bean, the instant will always be set to UTC timezone time.
I cannot follow here. If you change the Clock instance (i.e. declare a custom bean of that type) it will use whatever that bean returns for that method. There is currently no way to customize the time to be used as publication date logically different than "now". What would be a good use case to do that in the context of the registry?
Closing due to the lack of feedback.