Package org.symphonyoss.s2.fugue.pubsub
Class AbstractSubscriberManager<T extends AbstractSubscriberManager<T>>
- java.lang.Object
-
- org.symphonyoss.s2.common.fluent.Fluent<T>
-
- org.symphonyoss.s2.fugue.FugueLifecycleComponent<T>
-
- org.symphonyoss.s2.fugue.pubsub.AbstractSubscriberManager<T>
-
- Type Parameters:
T- Type of concrete manager, needed for fluent methods.
- All Implemented Interfaces:
org.symphonyoss.s2.common.fluent.IFluent<T>,org.symphonyoss.s2.fugue.IFugueComponent,org.symphonyoss.s2.fugue.IFugueLifecycleComponent,ISubscriberManager<T>
- Direct Known Subclasses:
AbstractPullSubscriberManager
public abstract class AbstractSubscriberManager<T extends AbstractSubscriberManager<T>> extends org.symphonyoss.s2.fugue.FugueLifecycleComponent<T> implements ISubscriberManager<T>
Base class for subscriber managers.- Author:
- Bruce Skingle
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractSubscriberManager.Builder<T extends AbstractSubscriberManager.Builder<T,B>,B extends AbstractSubscriberManager<B>>Builder.
-
Field Summary
Fields Modifier and Type Field Description protected org.symphonyoss.s2.fugue.config.IConfigurationconfig_protected org.symphonyoss.s2.fugue.counter.ICountercounter_protected static longFAILED_CONSUMER_RETRY_TIMEprotected static longFAILED_DEAD_LETTER_RETRY_TIMEprotected static longMESSAGE_PROCESSED_OKprotected org.symphonyoss.s2.fugue.naming.INameFactorynameFactory_protected com.google.common.collect.ImmutableList<ISubscription>subscribers_protected inttotalSubscriptionCnt_protected org.symphonyoss.s2.fugue.core.trace.ITraceContextTransactionFactorytraceFactory_protected org.symphonyoss.s2.fugue.pipeline.IThreadSafeErrorConsumer<String>unprocessableMessageConsumer_
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSubscriberManager(Class<T> type, AbstractSubscriberManager.Builder<?,T> builder)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidassertConfigurable()protected org.symphonyoss.s2.fugue.counter.ICountergetCounter()org.symphonyoss.s2.fugue.FugueLifecycleStategetLifecycleState()intgetTotalSubscriptionCnt()protected org.symphonyoss.s2.fugue.core.trace.ITraceContextTransactionFactorygetTraceFactory()longhandleMessage(org.symphonyoss.s2.fugue.pipeline.IThreadSafeRetryableConsumer<String> consumer, String payload, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace, String messageId)Handle the given message.protected abstract voidinitSubscription(ISubscription subscription)voidquiesce()protected voidsetLifeCycleState(org.symphonyoss.s2.fugue.FugueLifecycleState arg0)voidstart()protected abstract voidstartSubscriptions()voidstop()protected abstract voidstopSubscriptions()Stop all subscribers.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
FAILED_DEAD_LETTER_RETRY_TIME
protected static final long FAILED_DEAD_LETTER_RETRY_TIME
-
FAILED_CONSUMER_RETRY_TIME
protected static final long FAILED_CONSUMER_RETRY_TIME
-
MESSAGE_PROCESSED_OK
protected static final long MESSAGE_PROCESSED_OK
- See Also:
- Constant Field Values
-
nameFactory_
protected final org.symphonyoss.s2.fugue.naming.INameFactory nameFactory_
-
subscribers_
protected final com.google.common.collect.ImmutableList<ISubscription> subscribers_
-
traceFactory_
protected final org.symphonyoss.s2.fugue.core.trace.ITraceContextTransactionFactory traceFactory_
-
unprocessableMessageConsumer_
protected final org.symphonyoss.s2.fugue.pipeline.IThreadSafeErrorConsumer<String> unprocessableMessageConsumer_
-
config_
protected final org.symphonyoss.s2.fugue.config.IConfiguration config_
-
counter_
protected final org.symphonyoss.s2.fugue.counter.ICounter counter_
-
totalSubscriptionCnt_
protected final int totalSubscriptionCnt_
-
-
Constructor Detail
-
AbstractSubscriberManager
protected AbstractSubscriberManager(Class<T> type, AbstractSubscriberManager.Builder<?,T> builder)
-
-
Method Detail
-
getTotalSubscriptionCnt
public int getTotalSubscriptionCnt()
- Specified by:
getTotalSubscriptionCntin interfaceISubscriberManager<T extends AbstractSubscriberManager<T>>- Returns:
- The total number of subscriptions (product of topic and subscription) covered by this subscription configuration.
-
getCounter
protected org.symphonyoss.s2.fugue.counter.ICounter getCounter()
-
initSubscription
protected abstract void initSubscription(ISubscription subscription)
-
startSubscriptions
protected abstract void startSubscriptions()
-
stopSubscriptions
protected abstract void stopSubscriptions()
Stop all subscribers.
-
getTraceFactory
protected org.symphonyoss.s2.fugue.core.trace.ITraceContextTransactionFactory getTraceFactory()
-
start
public void start()
- Specified by:
startin interfaceorg.symphonyoss.s2.fugue.IFugueComponent
-
quiesce
public void quiesce()
- Specified by:
quiescein interfaceorg.symphonyoss.s2.fugue.IFugueComponent
-
stop
public void stop()
- Specified by:
stopin interfaceorg.symphonyoss.s2.fugue.IFugueComponent
-
handleMessage
public long handleMessage(org.symphonyoss.s2.fugue.pipeline.IThreadSafeRetryableConsumer<String> consumer, String payload, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace, String messageId)
Handle the given message.- Parameters:
consumer- The consumer for the message.payload- A received message.trace- A trace context.messageId- A unique ID for the message.- Returns:
- The number of milliseconds after which a retry should be made, or -1 if the message was processed and no retry is necessary.
-
assertConfigurable
protected void assertConfigurable()
-
setLifeCycleState
protected void setLifeCycleState(org.symphonyoss.s2.fugue.FugueLifecycleState arg0)
-
getLifecycleState
public org.symphonyoss.s2.fugue.FugueLifecycleState getLifecycleState()
-
-