Interface MessageListener<E>

Type Parameters:
E - message
All Superinterfaces:
All Known Subinterfaces:
All Known Implementing Classes:
ClientConsoleApp, ConsoleApp
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

public interface MessageListener<E>
extends EventListener
Message listener for ITopic. Provided that a MessageListener is not registered twice, a MessageListener will never be called concurrently. So there is no need to provide thread-safety on internal state in the MessageListener. Also there is no need to enforce safe publication, the ITopic is responsible for the memory consistency effects. In other words, there is no need to make internal fields of the MessageListener volatile or access them using synchronized blocks.
  • Method Summary

    Modifier and Type Method Description
    void onMessage​(Message<E> message)
    Invoked when a message is received for the added topic.
  • Method Details

    • onMessage

      void onMessage​(Message<E> message)
      Invoked when a message is received for the added topic. Note that 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.
      message - the message that is received for the added topic