Performance: Event publishing with ApplicationEventPublisher
MEDIUM IMPACT
This affects the responsiveness and throughput of the application by how events are published and handled asynchronously or synchronously.
@Async
public void handleEvent(CustomEvent event) { /* handle event asynchronously */ }
applicationEventPublisher.publishEvent(new CustomEvent(this, data));applicationEventPublisher.publishEvent(new CustomEvent(this, data)); // synchronous event handling
| Pattern | Thread Blocking | CPU Usage | Response Delay | Verdict |
|---|---|---|---|---|
| Synchronous Event Publishing | Blocks main thread until listeners finish | Lower CPU concurrency | Increases response time | [X] Bad |
| Asynchronous Event Publishing with @Async | No blocking of main thread | Higher CPU concurrency due to threads | Reduces response delay | [OK] Good |