EventBus is a publish-subscribe messaging library designed to facilitate decoupled communication between components in Java applications. It functions as a central hub where producers dispatch events that are routed to subscribers based on the class type of the payload. By using annotation-based markers, the system maps event handlers to specific data types, allowing different parts of an application to exchange information without requiring direct references between classes.
The library distinguishes itself through a focus on performance and execution control. It utilizes a compile-time indexing mechanism that generates static lookup tables, replacing slow runtime reflection with direct method calls to accelerate message routing. Furthermore, it provides a thread-aware dispatcher that allows developers to configure whether event handlers execute on the main interface thread, in background pools, or synchronously within the posting thread.
Beyond basic routing, the system supports advanced messaging patterns including priority-ordered delivery and sticky events. Sticky events maintain a memory-based cache of recent data, ensuring that late-registering subscribers automatically receive the most current state upon initialization. The library also offers granular control over the event lifecycle, enabling developers to cancel event propagation or manage custom thread pools and error handling strategies to maintain application responsiveness.