Package com.adaptris.core
Class RetryMessageErrorHandlerImp
- java.lang.Object
-
- com.adaptris.core.RootProcessingExceptionHandler
-
- com.adaptris.core.StandardProcessingExceptionHandler
-
- com.adaptris.core.RetryMessageErrorHandlerImp
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ErrorHandlerRegistrar
,EventHandlerAware
,ProcessingExceptionHandler
,StateManagedComponent
- Direct Known Subclasses:
RetryMessageErrorHandler
public abstract class RetryMessageErrorHandlerImp extends StandardProcessingExceptionHandler
Abstract MessageErrorHandler implementation that allows automatic retries for a problem message.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
RetryMessageErrorHandlerImp.RetryThread
Private thread used to resubmit messages.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ScheduledExecutorService
executor
protected java.util.List<AdaptrisMessage>
inProgress
protected static java.lang.String
IS_RETRY_KEY
protected static java.lang.String
RETRY_COUNT_KEY
protected java.util.List<AdaptrisMessage>
retryList
-
Fields inherited from class com.adaptris.core.RootProcessingExceptionHandler
log
-
-
Constructor Summary
Constructors Constructor Description RetryMessageErrorHandlerImp()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
failAllMessages()
protected void
failFutureMessages(boolean failFuture)
protected void
failMessage(AdaptrisMessage msg)
protected void
failMessage(java.lang.String s)
protected static java.util.Map<java.lang.String,Workflow>
filterStarted(java.util.Map<java.lang.String,Workflow> workflows)
TimeInterval
getRetryInterval()
java.lang.Integer
getRetryLimit()
Get the retry limit.void
handleProcessingException(AdaptrisMessage msg)
Handles error messages from Workflows by sending them to the configured error producer.protected void
scheduleNextRun(AdaptrisMessage msg)
void
setRetryInterval(TimeInterval interval)
Set the interval between attempts to retry a failed message.void
setRetryLimit(java.lang.Integer i)
Set the limit on the number of retries that a message may have.void
start()
Starts the component.void
stop()
Stop the componentprotected java.util.Collection<java.lang.String>
waitingForRetry()
-
Methods inherited from class com.adaptris.core.StandardProcessingExceptionHandler
close, getProcessingExceptionService, hasConfiguredBehaviour, init, logErrorMessage, prepare, registeredWorkflows, registerEventHandler, registerWorkflow, setProcessingExceptionService
-
Methods inherited from class com.adaptris.core.RootProcessingExceptionHandler
changeState, getAlwaysHandleException, getParent, getUniqueId, notifyParent, onChildError, registerDigester, registerParent, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveDigester, setAlwaysHandleException, setUniqueId
-
-
-
-
Field Detail
-
IS_RETRY_KEY
protected static final java.lang.String IS_RETRY_KEY
- See Also:
- Constant Field Values
-
RETRY_COUNT_KEY
protected static final java.lang.String RETRY_COUNT_KEY
- See Also:
- Constant Field Values
-
executor
protected transient java.util.concurrent.ScheduledExecutorService executor
-
retryList
protected transient java.util.List<AdaptrisMessage> retryList
-
inProgress
protected transient java.util.List<AdaptrisMessage> inProgress
-
-
Method Detail
-
handleProcessingException
public void handleProcessingException(AdaptrisMessage msg)
Description copied from class:StandardProcessingExceptionHandler
Handles error messages from Workflows by sending them to the configured error producer. The best practice would be for the service to write the message to the filesystem, which is pretty unlikely to fail.
- Specified by:
handleProcessingException
in interfaceProcessingExceptionHandler
- Overrides:
handleProcessingException
in classStandardProcessingExceptionHandler
- Parameters:
msg
- theAdaptrisMessage
to handle
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts 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:
start
in interfaceComponentLifecycle
- Overrides:
start
in classStandardProcessingExceptionHandler
- Throws:
CoreException
- wrapping any underlyingException
s
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop 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 aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
- Overrides:
stop
in classStandardProcessingExceptionHandler
-
setRetryLimit
public void setRetryLimit(java.lang.Integer i)
Set the limit on the number of retries that a message may have.- Parameters:
i
- the number of retries, if less than or equal to 0, then this is considered to be an infinite number of retries.
-
getRetryLimit
public java.lang.Integer getRetryLimit()
Get the retry limit.- Returns:
- the retry limit.
-
getRetryInterval
public TimeInterval getRetryInterval()
-
setRetryInterval
public void setRetryInterval(TimeInterval interval)
Set the interval between attempts to retry a failed message.- Parameters:
interval
- the interval; default is 10 minutes if not explicitly configured.
-
failAllMessages
protected void failAllMessages()
-
failFutureMessages
protected void failFutureMessages(boolean failFuture)
-
waitingForRetry
protected java.util.Collection<java.lang.String> waitingForRetry()
-
failMessage
protected void failMessage(java.lang.String s)
-
failMessage
protected void failMessage(AdaptrisMessage msg)
-
scheduleNextRun
protected void scheduleNextRun(AdaptrisMessage msg)
-
-