Class RoundRobinAsyncMessageDelivery

java.lang.Object
it.tidalwave.messagebus.spi.RoundRobinAsyncMessageDelivery
All Implemented Interfaces:
MessageDelivery

public class RoundRobinAsyncMessageDelivery extends Object implements MessageDelivery
An implementation of MessageDelivery that keeps a queue of messages for each topic, and dispatches them in a round-robin fashion, topic by topic, so a topic with many messages doesn't starve the others (see MultiQueue). Messages are dispatched by a number of workers, each of them permanently running in a thread of the Executor of the SimpleMessageBus.
Since:
2.2
Author:
Fabrizio Giudici
  • Constructor Details

    • RoundRobinAsyncMessageDelivery

      public RoundRobinAsyncMessageDelivery()
  • Method Details

    • initialize

      public void initialize(@Nonnull SimpleMessageBus messageBusSupport)
      Initializes this object. It is called by the constructor of SimpleMessageBus.
      Specified by:
      initialize in interface MessageDelivery
      Parameters:
      messageBusSupport - the message bus
    • deliverMessage

      public <T> void deliverMessage(@Nonnull Class<T> topic, @Nonnull T message)
      Delivers a message to the listeners.
      Specified by:
      deliverMessage in interface MessageDelivery
      Type Parameters:
      T - the static type of the topic
      Parameters:
      topic - the dynamic type of the topic
      message - the message