Class StoreMessageForRetryService
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,ConnectedService,MessageEventGenerator,Service,StateManagedComponent
Service which stores unacknowledged messages for future retry.
This class supports both synchronous and asynchronous acknowledgement. This is controlled by the field StoreMessageForRetryServiceTest#setAsynchronousAcknowledgment(boolean).
A message is deemed to be synchronously acknowledged if the wrapped service completes normally. In such cases it is not added to the retry store. If an exception occurs the message is added to the retry store and normal error handling is not invoked.
Where asynchronous acknowledgment is required and a message causes an exception, then the behaviour is determined by the async-auto-retry-on-fail setting. If set to true, then the message is added to the retry store for future retrying and message error handling is not invoked. If set to false, then normal message error handling is invoked. Where no exception occurs the message is added to the retry store to wait for asynchronous acknowledgment.
The following metadata keys control the behaviour of the underlying datastore:
- "retryAckId" contains the ID that will be used to correlate this message against any asynchronous confirmations; if not specified will default to the messages unique-id
- "retryAckInterval" contains the number of milliseconds between each retry attempt; if not specified then this service will fail.
- "retryRetries" contains the maximum number of retries (-1 for forever); if not specified then this service will fail.
-
Field Summary
Fields inherited from class com.adaptris.core.jdbc.retry.RetryServiceImp
marshallerFields inherited from class com.adaptris.core.ServiceImp
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanReturns true if asynchronous acknowledgment is required, otherwise false.Returns theServiceto use.protected voidvoidsetAsyncAutoRetryOnFail(boolean b) Flag for setting whether to store asynchronous acknolwedgement messages for retrying rather than invoking normal message error handling.voidsetAsynchronousAcknowledgment(boolean b) Sets whether asynchronous acknowledgment is required.voidSet the service which will initially produce the message to the remote system.voidstart()Starts the component.voidstop()Stop the componentprotected voidStop the service.Methods inherited from class com.adaptris.core.jdbc.retry.RetryServiceImp
closeJdbcService, doService, getConnection, getPruneAcknowledged, getRetryStore, initJdbcService, prepareService, setConnection, setPruneAcknowledged, setRetryStore, startServiceMethods inherited from class com.adaptris.core.jdbc.JdbcService
applyTimeout, closeService, createStatement, getConnection, getStatementTimeout, initService, prepare, prepareStatement, prepareStatement, setStatementTimeoutMethods 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, setUniqueIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueIdMethods inherited from interface com.adaptris.core.ComponentLifecycle
close, initMethods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpointMethods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueIdMethods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
Constructor Details
-
StoreMessageForRetryService
public StoreMessageForRetryService()Creates a new instance.
- Default service is
NullService - asynchronousAcknowledgment is false
- asyncAutoRetryOnFail is true
- Default service is
-
-
Method Details
-
start
Description 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 classRetryServiceImp- Throws:
CoreException- wrapping any underlyingExceptions- See Also:
-
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 classJdbcService- See Also:
-
performService
- Specified by:
performServicein classRetryServiceImp- Throws:
ServiceException- See Also:
-
RetryServiceImpTest#performService(com.adaptris.core.AdaptrisMessage)
-
getService
Returns the
Serviceto use.- Returns:
- the
Serviceto use
-
setService
Set the service which will initially produce the message to the remote system.- Parameters:
s- theServiceto use
-
getAsynchronousAcknowledgment
public boolean getAsynchronousAcknowledgment()Returns true if asynchronous acknowledgment is required, otherwise false.
- Returns:
- true if asynchronous acknowledgment is required, otherwise false
-
setAsynchronousAcknowledgment
public void setAsynchronousAcknowledgment(boolean b) Sets whether asynchronous acknowledgment is required.
- Parameters:
b- true if asynchronous acknowledgment is required, otherwise false
-
getAsyncAutoRetryOnFail
public boolean getAsyncAutoRetryOnFail()- Returns:
- the retryOnFail
-
setAsyncAutoRetryOnFail
public void setAsyncAutoRetryOnFail(boolean b) Flag for setting whether to store asynchronous acknolwedgement messages for retrying rather than invoking normal message error handling.- Parameters:
b- the retryOnFail to set
-
stopService
protected void stopService()Description copied from class:JdbcServiceStop the service.This is called after before the connection is stopped
- Specified by:
stopServicein classJdbcService
-