spring-projects / spring-modulith

Modular applications with Spring Boot
https://spring.io/projects/spring-modulith
Apache License 2.0
786 stars 131 forks source link

Customizing the Event Publication Date, but not working #684

Closed tlarbals824 closed 1 month ago

tlarbals824 commented 3 months ago

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?

odrotbohm commented 3 months ago

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?

odrotbohm commented 1 month ago

Closing due to the lack of feedback.