Class RetryingServiceWrapper
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.RetryingServiceWrapper
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,EventHandlerAware,MessageEventGenerator,Service,ServiceWrapper,StateManagedComponent
@ComponentProfile(summary="Retry a message periodically if the wrapped service fails", tag="service") public class RetryingServiceWrapper extends ServiceImp implements EventHandlerAware, ServiceWrapperThis service wrapper, will attempt to run the wrapped service and should the service fail with a
ServiceExceptionwe will attempt to retry the service according to your configuration.You can control then retrying behaviour with the following two configurable options;
- num-retries
- delay-between-retries
A value of zero for num-retries will retry the wrapped service infinitely. The default value if not set is 10.
The delay-between-retries is of type
TimeInterval. The default value if not set is 10 seconds.You may also force the wrapped service to be restarted upon each retry by setting restart-on-failure to true;
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description RetryingServiceWrapper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseService()voiddoService(AdaptrisMessage msg)Apply the service to the message.TimeIntervalgetDelayBetweenRetries()java.lang.IntegergetNumRetries()java.lang.BooleangetRestartOnFailure()ServicegetService()protected voidinitService()booleanisRestartOnFailure()voidprepare()Prepare for initialisation.voidregisterEventHandler(EventHandler eh)Register the current event handler against this component.voidsetDelayBetweenRetries(TimeInterval delayBetweenRetries)voidsetNumRetries(java.lang.Integer numRetries)voidsetRestartOnFailure(java.lang.Boolean restartOnFailure)voidsetService(Service service)voidstart()Starts the component.voidstop()Stop the componentService[]wrappedServices()Return all the services that are wrapped by this service.-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:ServiceApply the service to the message.
- Specified by:
doServicein interfaceService- Parameters:
msg- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Specified by:
preparein interfaceComponentLifecycleExtension- Throws:
CoreException
-
initService
protected void initService() throws CoreException- Specified by:
initServicein classServiceImp- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeServicein classServiceImp
-
start
public void start() throws CoreExceptionDescription copied from interface:ComponentLifecycleStarts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer, calling start will begin message delivery.- Specified by:
startin interfaceComponentLifecycle- Overrides:
startin classServiceImp- Throws:
CoreException- wrapping any underlyingExceptions
-
stop
public void stop()
Description copied from interface:ComponentLifecycleStop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer, calling stop will pause message delivery. Throwing aRuntimeExceptionmay cause unintended consequences- Specified by:
stopin interfaceComponentLifecycle- Overrides:
stopin classServiceImp
-
getService
public Service getService()
-
setService
public void setService(Service service)
-
getNumRetries
public java.lang.Integer getNumRetries()
-
setNumRetries
public void setNumRetries(java.lang.Integer numRetries)
-
getDelayBetweenRetries
public TimeInterval getDelayBetweenRetries()
-
setDelayBetweenRetries
public void setDelayBetweenRetries(TimeInterval delayBetweenRetries)
-
isRestartOnFailure
public boolean isRestartOnFailure()
-
setRestartOnFailure
public void setRestartOnFailure(java.lang.Boolean restartOnFailure)
-
getRestartOnFailure
public java.lang.Boolean getRestartOnFailure()
-
registerEventHandler
public void registerEventHandler(EventHandler eh)
Description copied from interface:EventHandlerAwareRegister the current event handler against this component.- Specified by:
registerEventHandlerin interfaceEventHandlerAware- Parameters:
eh- the event handler currently in use.
-
wrappedServices
public Service[] wrappedServices()
Description copied from interface:ServiceWrapperReturn all the services that are wrapped by this service.- Specified by:
wrappedServicesin interfaceServiceWrapper- Returns:
- an array of wrapped services.
-
-