Class ConsumerSubscriber<T>

  • Type Parameters:
    T - the type of messages of the Subscriber can accept
    All Implemented Interfaces:
    Subscriber<T>

    public final class ConsumerSubscriber<T>
    extends Object
    implements Subscriber<T>
    A Subscriber that calls the given consumer for each message.
    See Also:
    EventMaid Documentation
    • Constructor Detail

      • ConsumerSubscriber

        public ConsumerSubscriber()
    • Method Detail

      • consumerSubscriber

        public static <T> ConsumerSubscriber<T> consumerSubscriber​(Consumer<T> consumer)
        Factory method to create a new ConsumerSubscriber.
        Type Parameters:
        T - the type of the message the Subscriber accepts
        Parameters:
        consumer - the consumer to call for each message
        Returns:
        a new ConsumerSubscriber
      • accept

        public AcceptingBehavior accept​(T message)
        Description copied from interface: Subscriber
        Delivers the message to the Subscriber. The Subscriber can decide, if the delivery continues or is preempted by returning the respective AcceptingBehavior.
        Specified by:
        accept in interface Subscriber<T>
        Parameters:
        message - the message
        Returns:
        AcceptingBehavior to continue or preempt delivery
      • getSubscriptionId

        public SubscriptionId getSubscriptionId()
        Description copied from interface: Subscriber
        The unique and constant SubscriptionId of the Subscriber.
        Specified by:
        getSubscriptionId in interface Subscriber<T>
        Returns:
        the Subscriber's SubscriptionId