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.voidregister(String address, Consumer<Object> handler, DispatchMode perHandlerMode) Registers a handler for the specified address using a specific dispatch strategy.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
-
register
Registers a handler for the specified address using a specific dispatch strategy.- Parameters:
address- the address to listen onhandler- aConsumerthat processes incoming messagesperHandlerMode- theDispatchModecontrolling on which thread this handler runs
-
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.
-
