Package com.framed.core
Interface EventBus
- All Known Implementing Classes:
LocalEventBus,SocketEventBus
public interface EventBus
Defines a simple event bus mechanism for message-based communication between components and/or services.
Implementations of this interface allow registering handlers and sending or publishing messages to specific addresses.
The event bus supports two messaging patterns:
- Send: Delivers a message to a single handler registered for the given address.
- Publish: Broadcasts a message to all handlers registered for the given address.
-
Method Summary
Modifier and TypeMethodDescriptionvoidPublishes a message to all handlers registered for the given address.voidRegisters a handler for messages sent to the specified address.voidSends a message to a single handler registered for the given address.voidshutdown()Shutdown method of the EventBus.
-
Method Details
-
register
Registers a handler for messages sent to the specified address.- Parameters:
address- the address to listen onhandler- aConsumerthat processes incoming messages
-
send
Sends a message to a single handler registered for the given address.- Parameters:
address- the target addressmessage- the message to send
-
publish
Publishes a message to all handlers registered for the given address.- Parameters:
address- the target addressmessage- the message to broadcast
-
shutdown
void shutdown()Shutdown method of the EventBus. Depending on the implementation, this should stop all workers.
-