@ComponentProfile(summary="Retry a message periodically if the wrapped service fails",
tag="service")
public class RetryingServiceWrapper
extends ServiceImp
implements EventHandlerAware, ServiceWrapper
This service wrapper, will attempt to run the wrapped service and should the service fail with
a ServiceException we will attempt to retry the service according to your configuration.
You can control then retrying behaviour with the following two configurable options;
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;
log| Constructor and Description |
|---|
RetryingServiceWrapper() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeService() |
void |
doService(AdaptrisMessage msg)
Apply the service to the message.
|
TimeInterval |
getDelayBetweenRetries() |
java.lang.Integer |
getNumRetries() |
java.lang.Boolean |
getRestartOnFailure() |
Service |
getService() |
protected void |
initService() |
boolean |
isRestartOnFailure() |
void |
prepare()
Prepare for initialisation.
|
void |
registerEventHandler(EventHandler eh)
Register the current event handler against this component.
|
void |
setDelayBetweenRetries(TimeInterval delayBetweenRetries) |
void |
setNumRetries(java.lang.Integer numRetries) |
void |
setRestartOnFailure(java.lang.Boolean restartOnFailure) |
void |
setService(Service service) |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
Service[] |
wrappedServices()
Return all the services that are wrapped by this service.
|
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueIdclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcontinueOnFailure, isBranching, setUniqueIdcreateName, createQualifier, isTrackingEndpointchangeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentStategetUniqueIdclose, initpublic void doService(AdaptrisMessage msg) throws ServiceException
ServiceApply the service to the message.
doService in interface Servicemsg - the AdaptrisMessage to processServiceException - wrapping any underlying Exceptionspublic void prepare()
throws CoreException
ComponentLifecycleExtensionprepare in interface ComponentLifecycleExtensionCoreExceptionprotected void initService()
throws CoreException
initService in class ServiceImpCoreExceptionprotected void closeService()
closeService in class ServiceImppublic void start()
throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer, calling start
will begin message delivery.
start in interface ComponentLifecyclestart in class ServiceImpCoreException - wrapping any underlying Exceptionspublic void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer, calling stop
will pause message delivery. Throwing a RuntimeException may cause unintended consequences
stop in interface ComponentLifecyclestop in class ServiceImppublic Service getService()
public void setService(Service service)
public java.lang.Integer getNumRetries()
public void setNumRetries(java.lang.Integer numRetries)
public TimeInterval getDelayBetweenRetries()
public void setDelayBetweenRetries(TimeInterval delayBetweenRetries)
public boolean isRestartOnFailure()
public void setRestartOnFailure(java.lang.Boolean restartOnFailure)
public java.lang.Boolean getRestartOnFailure()
public void registerEventHandler(EventHandler eh)
EventHandlerAwareregisterEventHandler in interface EventHandlerAwareeh - the event handler currently in use.public Service[] wrappedServices()
ServiceWrapperwrappedServices in interface ServiceWrapper