Package it.tidalwave.messagebus
Interface MessageBus
- All Known Implementing Classes:
SimpleMessageBus
public interface MessageBus
A simple message bus for a local publish/subscribe facility.
- Author:
- Fabrizio Giudici
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A listener to receive notifications from aMessageBus
. -
Method Summary
Modifier and TypeMethodDescription<T> void
Publishes the given message and topic.<T> void
publish
(T message) Publishes the given event.<T> void
subscribe
(Class<T> topic, MessageBus.Listener<T> listener) Subscribes aMessageBus.Listener
to a topic.void
unsubscribe
(MessageBus.Listener<?> listener) Unsubscribes aMessageBus.Listener
.
-
Method Details
-
publish
<T> void publish(@Nonnull T message) Publishes the given event. The topic is the class of the event.- Type Parameters:
T
- the static type of the topic- Parameters:
message
- the event
-
publish
Publishes the given message and topic. Passing an explicit topic can be useful when dealing with a hierarchy of events (so, perhaps a subclass is passed but the topic is the root of the hierarchy).- Type Parameters:
T
- the static type of the topic- Parameters:
topic
- the topicmessage
- the message
-
subscribe
Subscribes aMessageBus.Listener
to a topic.- Type Parameters:
T
- the static type of the topic- Parameters:
topic
- the topiclistener
- the listener
-
unsubscribe
Unsubscribes aMessageBus.Listener
.- Parameters:
listener
- the listener
-