Class ConsumerSubscriber<T>
- java.lang.Object
-
- de.quantummaid.eventmaid.subscribing.ConsumerSubscriber<T>
-
- Type Parameters:
T- the type of messages of theSubscribercan accept
- All Implemented Interfaces:
Subscriber<T>
public final class ConsumerSubscriber<T> extends Object implements Subscriber<T>
ASubscriberthat calls the givenconsumerfor each message.- See Also:
- EventMaid Documentation
-
-
Constructor Summary
Constructors Constructor Description ConsumerSubscriber()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AcceptingBehavioraccept(T message)Delivers the message to theSubscriber.static <T> ConsumerSubscriber<T>consumerSubscriber(Consumer<T> consumer)Factory method to create a newConsumerSubscriber.SubscriptionIdgetSubscriptionId()The unique and constantSubscriptionIdof theSubscriber.
-
-
-
Method Detail
-
consumerSubscriber
public static <T> ConsumerSubscriber<T> consumerSubscriber(Consumer<T> consumer)
Factory method to create a newConsumerSubscriber.- Type Parameters:
T- the type of the message theSubscriberaccepts- Parameters:
consumer- theconsumerto call for each message- Returns:
- a new
ConsumerSubscriber
-
accept
public AcceptingBehavior accept(T message)
Description copied from interface:SubscriberDelivers the message to theSubscriber. TheSubscribercan decide, if the delivery continues or is preempted by returning the respectiveAcceptingBehavior.- Specified by:
acceptin interfaceSubscriber<T>- Parameters:
message- the message- Returns:
AcceptingBehaviorto continue or preempt delivery
-
getSubscriptionId
public SubscriptionId getSubscriptionId()
Description copied from interface:SubscriberThe unique and constantSubscriptionIdof theSubscriber.- Specified by:
getSubscriptionIdin interfaceSubscriber<T>- Returns:
- the
Subscriber'sSubscriptionId
-
-