-
Notifications
You must be signed in to change notification settings - Fork 170
Description
Problem / Motivation
Currently, when publishing domain events in Spring Modulith, the user or calling component cannot know whether the event processing succeeded or failed.
This limits the ability to provide immediate feedback to the user or handle failures programmatically.
Proposed Enhancement
I propose one or more of the following enhancements:
Failure Callback Interface
Provide an interface (e.g., EventFailureHandler) that developers can implement.
When an event fails to execute, the event source information is passed to this handler, allowing developers to implement custom logic (e.g., retry, logging, sending notifications).
Built-in Notification / Messaging Module
Spring Modulith could provide a default mechanism to notify clients/frontends when an event fails.
For example, a simple message bus or WebSocket/REST callback to inform the frontend of the failure.
Success/Failure Acknowledgment for Event Publishing
Optionally, event publishing could return a success/failure status, or a CompletableFuture indicating the outcome of event processing.
Benefits
Improves UX by allowing immediate feedback on event outcomes.
Provides hooks for handling domain event failures in a structured way.
Enables developers to integrate notifications or compensating actions seamlessly.
public class MyEventFailureHandler implements EventFailureHandler {
@Override
public void handleFailure(DomainEvent event, Throwable cause) {
// Send notification to frontend
// Log error
// Trigger compensating transaction
}
}