Class FilesystemRetryStore
- java.lang.Object
-
- com.adaptris.core.http.jetty.retry.FilesystemRetryStore
-
- All Implemented Interfaces:
ComponentLifecycle
,ComponentLifecycleExtension
,RetryStore
@ComponentProfile(summary="Store message for retry on the filesystem.", since="3.11.1") public class FilesystemRetryStore extends java.lang.Object implements RetryStore
Writes data into local storage for retry.While not tightly coupled with
RetryFromJetty
it is designed somewhat exclusively for that. You may be able to make use of it in other ways, but behaviour may change unexpectedly due to changes inRetryFromJetty
.The behaviour of this store will assume that each
message-id
will form a sub-directory offbaseUrl
. Metadata will be stored[baseUrl]/[msgId]/metadata.properties
as a standard properties file; the payload will be stored in[baseUrl]/[msgId]/payload.blob
.- Since:
- 3.11.1
In the adapter configuration file this class is aliased as retry-store-filesystem which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Constructor Summary
Constructors Constructor Description FilesystemRetryStore()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acknowledge(java.lang.String acknowledgeId)
Acknowledge that the message with the passed ID has now been successfully processed and should not be retried again.AdaptrisMessage
buildForRetry(java.lang.String msgId, java.util.Map<java.lang.String,java.lang.String> metadata, AdaptrisMessageFactory msgFac)
Build the message for retrying from the store.protected static RemoteBlob
createForReport(java.io.File baseDir)
boolean
delete(java.lang.String msgId)
Delete a message from the store (optional operation).void
deleteAcknowledged()
Delete any messages that have been successfully Acknowledged.java.lang.String
getBaseUrl()
The base URLfile:///...
where we can discover files.java.util.Map<java.lang.String,java.lang.String>
getMetadata(java.lang.String msgId)
Retrieve the metadata associated with the msgId the store.void
makeConnection(AdaptrisConnection connection)
Used for any implementations that have a connected RetryStorejava.util.List<AdaptrisMessage>
obtainExpiredMessages()
Obtain a list ofAdaptrisMessage
s which meet the expiration criteria.java.util.List<AdaptrisMessage>
obtainMessagesToRetry()
Obtain a list ofAdaptrisMessage
s which meet the criteria for retrying.void
prepare()
Prepare for initialisation.java.lang.Iterable<RemoteBlob>
report()
Report on a list of blobs that is present in the store (optional operation).void
setBaseUrl(java.lang.String baseUrl)
The base URLfile:///...
where we can discover files.void
updateRetryCount(java.lang.String messageId)
Update the number of retries which have taken place for the message with the passed ID.FilesystemRetryStore
withBaseUrl(java.lang.String s)
void
write(AdaptrisMessage msg)
Write a message to the store.-
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.ComponentLifecycle
close, init, start, stop
-
Methods inherited from interface com.adaptris.core.http.jetty.retry.RetryStore
buildForRetry, buildForRetry
-
-
-
-
Method Detail
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Specified by:
prepare
in interfaceRetryStore
- Throws:
CoreException
-
write
public void write(AdaptrisMessage msg) throws InterlokException
Description copied from interface:RetryStore
Write a message to the store.- Specified by:
write
in interfaceRetryStore
- Throws:
InterlokException
-
buildForRetry
public AdaptrisMessage buildForRetry(java.lang.String msgId, java.util.Map<java.lang.String,java.lang.String> metadata, AdaptrisMessageFactory msgFac) throws InterlokException
Description copied from interface:RetryStore
Build the message for retrying from the store.- Specified by:
buildForRetry
in interfaceRetryStore
- Parameters:
msgId
- the message id.metadata
- the metadata you want to apply to the messagemsgFac
- the message factory to use- Returns:
- a message.
- Throws:
CoreException
InterlokException
-
getMetadata
public java.util.Map<java.lang.String,java.lang.String> getMetadata(java.lang.String msgId) throws InterlokException
Description copied from interface:RetryStore
Retrieve the metadata associated with the msgId the store.This is used to assert that the workflow exists in this instance for that message; there is no point building the whole message only to fail because the workflow doesn't exist.
- Specified by:
getMetadata
in interfaceRetryStore
- Throws:
InterlokException
- if no metadata could be retrieved (e.g the msgId doesn't exist)
-
report
public java.lang.Iterable<RemoteBlob> report() throws InterlokException
Description copied from interface:RetryStore
Report on a list of blobs that is present in the store (optional operation).- Specified by:
report
in interfaceRetryStore
- Throws:
InterlokException
-
delete
public boolean delete(java.lang.String msgId) throws InterlokException
Description copied from interface:RetryStore
Delete a message from the store (optional operation).- Specified by:
delete
in interfaceRetryStore
- Throws:
InterlokException
-
createForReport
protected static RemoteBlob createForReport(java.io.File baseDir)
-
withBaseUrl
public FilesystemRetryStore withBaseUrl(java.lang.String s)
-
acknowledge
public void acknowledge(java.lang.String acknowledgeId) throws InterlokException
Description copied from interface:RetryStore
Acknowledge that the message with the passed ID has now been successfully processed and should not be retried again. NB this method does not throw an Exception if the acknowledge ID does not exist in the store.
- Specified by:
acknowledge
in interfaceRetryStore
- Parameters:
acknowledgeId
- the acknowledge ID of the message to acknowledge- Throws:
InterlokException
- wrapping anyException
which occurs
-
deleteAcknowledged
public void deleteAcknowledged() throws InterlokException
Description copied from interface:RetryStore
Delete any messages that have been successfully Acknowledged.- Specified by:
deleteAcknowledged
in interfaceRetryStore
- Throws:
InterlokException
- wrapping anyException
which occurs
-
obtainExpiredMessages
public java.util.List<AdaptrisMessage> obtainExpiredMessages() throws InterlokException
Description copied from interface:RetryStore
Obtain a list of
AdaptrisMessage
s which meet the expiration criteria. In the most abstract sense, expired messages are those that have exceeded their max retry count but not yet been acknowledged.- Specified by:
obtainExpiredMessages
in interfaceRetryStore
- Returns:
- a list of
AdaptrisMessage
s which meet the expiration criteria. - Throws:
InterlokException
- wrapping anyException
which occurs
-
obtainMessagesToRetry
public java.util.List<AdaptrisMessage> obtainMessagesToRetry() throws InterlokException
Description copied from interface:RetryStore
Obtain a list of
AdaptrisMessage
s which meet the criteria for retrying.- Specified by:
obtainMessagesToRetry
in interfaceRetryStore
- Returns:
- a list of
AdaptrisMessage
s which meet the criteria for retrying - Throws:
InterlokException
- wrapping anyException
which occurs
-
updateRetryCount
public void updateRetryCount(java.lang.String messageId) throws InterlokException
Description copied from interface:RetryStore
Update the number of retries which have taken place for the message with the passed ID. NB this method does not throw an Exception if an attempt is made to update the retry count for a message ID which does not exist in the store.
- Specified by:
updateRetryCount
in interfaceRetryStore
- Parameters:
messageId
- the ID of the message to update- Throws:
InterlokException
- wrapping anyException
which occurs
-
makeConnection
public void makeConnection(AdaptrisConnection connection)
Description copied from interface:RetryStore
Used for any implementations that have a connected RetryStore
- Specified by:
makeConnection
in interfaceRetryStore
-
getBaseUrl
public java.lang.String getBaseUrl()
The base URLfile:///...
where we can discover files.
-
setBaseUrl
public void setBaseUrl(java.lang.String baseUrl)
The base URLfile:///...
where we can discover files.
-
-