Skip to content

Support Custom Event Name via Annotation for Stored Events #1218

@zeng-alt

Description

@zeng-alt

I’m currently using Spring Modulith’s event publication mechanism, and I noticed that when events are stored in the database (e.g., using EventPublicationRegistry with a persistent EventPublicationRepository), the system stores basic metadata such as the event type and timestamp.

It would be useful for us to store a custom event name (a human-readable identifier) in addition to the event’s class name. This would help in logging, querying, or categorizing events more easily—especially when the same event class might be reused in different contexts.

I’d like to propose an enhancement where we could annotate the event class with a custom name, for example:

@EventName("user.registered")
public class UserRegisteredEvent {

}

The framework could then optionally persist this value along with the event metadata.

Benefits:

Makes stored event data more readable and meaningful

Helps categorize and filter events

Can aid integration with observability tools or analytics dashboards

Would this be a reasonable addition? If so, I’d be happy to help contribute or collaborate on a PR.

Thanks for the great work on Spring Modulith!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions