Package com.hazelcast.topic
Interface MessageListener<E>
-
- Type Parameters:
E
- message type
- All Superinterfaces:
java.util.EventListener
- All Known Subinterfaces:
ReliableMessageListener<E>
- All Known Implementing Classes:
ConsoleApp
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface MessageListener<E> extends java.util.EventListener
Message listener forITopic
.A MessageListener will never be called concurrently (provided that it's not registered twice). So there is no need to synchronize access to the state it reads or writes. Also there is no need to synchronize when publishing to the ITopic, the ITopic is responsible for memory consistency effects. In other words, there is no need to make fields of the MessageListener volatile or access them using synchronized blocks.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
onMessage(Message<E> message)
Invoked when a message is received for the topic.
-
-
-
Method Detail
-
onMessage
void onMessage(Message<E> message)
Invoked when a message is received for the topic. Note that the topic guarantees message ordering. Therefore there is only one thread invoking onMessage. The user should not keep the thread busy, but preferably should dispatch it via an Executor. This will increase the performance of the topic.- Parameters:
message
- the message that is received for the topic
-
-