Class Subscription<T>
- java.lang.Object
-
- de.quantummaid.eventmaid.channel.action.Subscription<T>
-
- Type Parameters:
T- the type of messages of theChannel
- All Implemented Interfaces:
Action<T>
public final class Subscription<T> extends Object implements Action<T>
ASubscriptionobject manages a list ofSubscribers. Each message is distributed to eachSubscriber, if no exception occurred.- See Also:
- EventMaid Documentation
-
-
Constructor Summary
Constructors Constructor Description Subscription()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SubscriptionIdaddRawSubscriber(Subscriber<ProcessingContext<T>> subscriber)Adds aSubscriber, that gets access to the underlyingProcessingContextobject.SubscriptionIdaddRawSubscriber(Consumer<ProcessingContext<T>> consumer)Adds a the consumer wrapped in aSubscriberobject, that gets access to the underlyingProcessingContextobject.SubscriptionIdaddSubscriber(Subscriber<T> subscriber)Adds aSubscriber.SubscriptionIdaddSubscriber(Consumer<T> consumer)Adds a the consumer wrapped in aSubscriberobject.List<Subscriber<?>>getAllSubscribers()booleanhasSubscribers()Returns if at least one subscriber exists.voidremoveSubscriber(Subscriber<?> subscriber)Removes the givenSubscriber.voidremoveSubscriber(SubscriptionId subscriptionId)Removes allSubscribersthat match the givenSubscriptionId.static <T> Subscription<T>subscription()Creates a newSubscriptionobject.
-
-
-
Method Detail
-
subscription
public static <T> Subscription<T> subscription()
Creates a newSubscriptionobject.- Type Parameters:
T- the type of messages of theChannel- Returns:
- a new
Subscriptionobject
-
addSubscriber
public SubscriptionId addSubscriber(Consumer<T> consumer)
Adds a the consumer wrapped in aSubscriberobject.- Parameters:
consumer- the consumingSubscriberto be added- Returns:
- the wrapping
Subscriber'sSubscriptionId
-
addSubscriber
public SubscriptionId addSubscriber(Subscriber<T> subscriber)
Adds aSubscriber.- Parameters:
subscriber- theSubscriberto be added- Returns:
- the wrapping
Subscriber'sSubscriptionId
-
addRawSubscriber
public SubscriptionId addRawSubscriber(Consumer<ProcessingContext<T>> consumer)
Adds a the consumer wrapped in aSubscriberobject, that gets access to the underlyingProcessingContextobject.- Parameters:
consumer- the consumingSubscriberto be added- Returns:
- the wrapping
Subscriber'sSubscriptionId
-
addRawSubscriber
public SubscriptionId addRawSubscriber(Subscriber<ProcessingContext<T>> subscriber)
Adds aSubscriber, that gets access to the underlyingProcessingContextobject.- Parameters:
subscriber- theSubscriberto be added- Returns:
- the wrapping
Subscriber'sSubscriptionId
-
hasSubscribers
public boolean hasSubscribers()
Returns if at least one subscriber exists.- Returns:
trueif at least oneSubscriberexists,falseotherwise
-
getAllSubscribers
public List<Subscriber<?>> getAllSubscribers()
-
removeSubscriber
public void removeSubscriber(Subscriber<?> subscriber)
Removes the givenSubscriber.- Parameters:
subscriber- theSubscriberto be removed
-
removeSubscriber
public void removeSubscriber(SubscriptionId subscriptionId)
Removes allSubscribersthat match the givenSubscriptionId.- Parameters:
subscriptionId- theSubscriptionId, for which allSubscribersshould be removed.
-
-