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
marshaller
Fields inherited from class com.adaptris.core.ServiceImp
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
Returns true if asynchronous acknowledgment is required, otherwise false.Returns theService
to use.protected void
void
setAsyncAutoRetryOnFail
(boolean b) Flag for setting whether to store asynchronous acknolwedgement messages for retrying rather than invoking normal message error handling.void
setAsynchronousAcknowledgment
(boolean b) Sets whether asynchronous acknowledgment is required.void
Set the service which will initially produce the message to the remote system.void
start()
Starts the component.void
stop()
Stop the componentprotected void
Stop the service.Methods inherited from class com.adaptris.core.jdbc.retry.RetryServiceImp
closeJdbcService, doService, getConnection, getPruneAcknowledged, getRetryStore, initJdbcService, prepareService, setConnection, setPruneAcknowledged, setRetryStore, startService
Methods inherited from class com.adaptris.core.jdbc.JdbcService
applyTimeout, closeService, createStatement, getConnection, getStatementTimeout, initService, prepare, prepareStatement, prepareStatement, setStatementTimeout
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
-
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: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 classRetryServiceImp
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
-
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 classJdbcService
- See Also:
-
performService
- Specified by:
performService
in classRetryServiceImp
- Throws:
ServiceException
- See Also:
-
RetryServiceImpTest#performService(com.adaptris.core.AdaptrisMessage)
-
getService
Returns the
Service
to use.- Returns:
- the
Service
to use
-
setService
Set the service which will initially produce the message to the remote system.- Parameters:
s
- theService
to 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:JdbcService
Stop the service.This is called after before the connection is stopped
- Specified by:
stopService
in classJdbcService
-