Class RetryFromJetty
- java.lang.Object
-
- com.adaptris.core.FailedMessageRetrierImp
-
- com.adaptris.core.http.jetty.retry.RetryFromJetty
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,FailedMessageRetrier
@ComponentProfile(summary="Listen for HTTP traffic on the specified URI and retry messages", recommended={EmbeddedConnection.class,JettyConnection.class}, since="3.11.1") public class RetryFromJetty extends FailedMessageRetrierImp
FailedMessageRetrier
implementation that retries upon demand.This implementation listens on the specified jetty endpoint(s) and allows you to retry failed message by ID and list the contents of the data store that contains failed messages. Sometimes we can't rely on standard error handlers/retriers to retry failed messages. This is intended to codify some of the concepts discussed here into a simpler configuration chain.
This jetty implementation allows two modes of operation. Listing the failed messages, retrying a message, deleting messages from the store.
curl -XGET http://localhost:8080/api/failed/list
gives you a list of message ids that are listed in the storecurl -XPOST http://localhost:8080/api/retry/[msgId]
will attempt to resubmit the message to the appropriate workflow; returning a 202 upon successcurl -XDELETE http://localhost:8080/api/failed/delete/[msgId]
will attempt to delete the message from the store
While DELETE is available, this implementation doesn't make any checks that the messages that you have retried have been retried successfuly. It is expected that you have separate tooling that allows you to verify that retried-messages are ultimately sucessfully before triggering the delete. If you ask for a message to be deleted from the store, then that is what happens.
- Since:
- 3.11.1
In the adapter configuration file this class is aliased as retry-via-jetty which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONTENT_TYPE_EXPR
static java.lang.String
CONTENT_TYPE_METADATA_KEY
static java.lang.String
DEFAULT_DELETE_PREFIX
static java.lang.String
DEFAULT_ENDPOINT_PREFIX
static java.lang.String
DEFAULT_REPORTING_ENDPOINT
protected static java.lang.String
HTTP_ACCEPTED
protected static java.lang.String
HTTP_BAD
protected static java.lang.String
HTTP_ERROR
protected static java.lang.String
HTTP_NOT_FOUND
protected static java.lang.String
HTTP_OK
-
Constructor Summary
Constructors Constructor Description RetryFromJetty()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component.protected static void
executeQuietly(Service service, AdaptrisMessage msg)
AdaptrisConnection
getConnection()
The underlying Jetty connection.java.lang.String
getDeleteEndpointPrefix()
The delete endpoint.java.lang.String
getDeleteHttpMethod()
The HTTP method which is required for deleting messages from the retry store; the default is DELETE.@NonNull ReportBuilder
getReportBuilder()
How to build reports.java.lang.String
getReportingEndpoint()
The endpoint that allows reporting on what has failed.java.lang.String
getRetryEndpointPrefix()
The retry endpoint.java.lang.String
getRetryHttpMethod()
The HTTP method which is required for retries; the default is POST.@NonNull RetryStore
getRetryStore()
Where messages are stored for retries.void
init()
Initialises the component.void
prepare()
Prepare for initialisation.void
setConnection(AdaptrisConnection connection)
The underlying Jetty connection.void
setDeleteEndpointPrefix(java.lang.String deleteEndpointPrefix)
The delete endpoint.void
setDeleteHttpMethod(java.lang.String deleteHttpMethod)
The HTTP method which is required for deleting messages from the retry store; the default is DELETE.void
setReportBuilder(@NonNull ReportBuilder reportBuilder)
How to build reports.void
setReportingEndpoint(java.lang.String reportingEndpoint)
The endpoint that allows reporting on what has failed.void
setRetryEndpointPrefix(java.lang.String retryEndpointPrefix)
The retry endpoint.void
setRetryHttpMethod(java.lang.String retryHttpMethod)
The HTTP method which is required for retries; the default is POST.void
setRetryStore(@NonNull RetryStore retryStore)
Where messages are stored for retries.void
start()
Starts the component.void
stop()
Stop the componentRetryFromJetty
withReportBuilder(ReportBuilder b)
RetryFromJetty
withRetryStore(RetryStore rs)
-
Methods inherited from class com.adaptris.core.FailedMessageRetrierImp
addWorkflow, clearWorkflows, getUniqueId, getWorkflow, getWorkflow, getWorkflows, registeredWorkflowIds, setUniqueId, updateRetryCountMetadata
-
-
-
-
Field Detail
-
DEFAULT_ENDPOINT_PREFIX
public static final java.lang.String DEFAULT_ENDPOINT_PREFIX
- See Also:
- Constant Field Values
-
DEFAULT_REPORTING_ENDPOINT
public static final java.lang.String DEFAULT_REPORTING_ENDPOINT
- See Also:
- Constant Field Values
-
DEFAULT_DELETE_PREFIX
public static final java.lang.String DEFAULT_DELETE_PREFIX
- See Also:
- Constant Field Values
-
CONTENT_TYPE_METADATA_KEY
public static final java.lang.String CONTENT_TYPE_METADATA_KEY
- See Also:
- Constant Field Values
-
CONTENT_TYPE_EXPR
public static final java.lang.String CONTENT_TYPE_EXPR
- See Also:
- Constant Field Values
-
HTTP_OK
protected static final java.lang.String HTTP_OK
- See Also:
- Constant Field Values
-
HTTP_ACCEPTED
protected static final java.lang.String HTTP_ACCEPTED
- See Also:
- Constant Field Values
-
HTTP_ERROR
protected static final java.lang.String HTTP_ERROR
- See Also:
- Constant Field Values
-
HTTP_BAD
protected static final java.lang.String HTTP_BAD
- See Also:
- Constant Field Values
-
HTTP_NOT_FOUND
protected static final java.lang.String HTTP_NOT_FOUND
- See Also:
- Constant Field Values
-
-
Method Detail
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Throws:
CoreException
- wrapping any underlyingException
s
-
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.- 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
-
close
public void close()
Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences
-
withRetryStore
public RetryFromJetty withRetryStore(RetryStore rs)
-
withReportBuilder
public RetryFromJetty withReportBuilder(ReportBuilder b)
-
executeQuietly
protected static void executeQuietly(Service service, AdaptrisMessage msg)
-
getRetryEndpointPrefix
public java.lang.String getRetryEndpointPrefix()
The retry endpoint.The default if not explicitly specified is "/api/retry/", note the trailing
"/"
. The expectation is that when clients interact with the endpoint it will be in the form/prefix/'msgId'
-
setRetryEndpointPrefix
public void setRetryEndpointPrefix(java.lang.String retryEndpointPrefix)
The retry endpoint.The default if not explicitly specified is "/api/retry/", note the trailing
"/"
. The expectation is that when clients interact with the endpoint it will be in the form/prefix/'msgId'
-
getReportingEndpoint
public java.lang.String getReportingEndpoint()
The endpoint that allows reporting on what has failed.The default if not explicitly specified is "/api/failed/list".
-
setReportingEndpoint
public void setReportingEndpoint(java.lang.String reportingEndpoint)
The endpoint that allows reporting on what has failed.The default if not explicitly specified is "/api/failed/list".
-
getDeleteEndpointPrefix
public java.lang.String getDeleteEndpointPrefix()
The delete endpoint.The default if not explicitly specified is "/api/failed/delete/", note the trailing
"/"
. The expectation is that when clients interact with the endpoint it will be in the form/prefix/'msgId'
-
setDeleteEndpointPrefix
public void setDeleteEndpointPrefix(java.lang.String deleteEndpointPrefix)
The delete endpoint.The default if not explicitly specified is "/api/failed/delete/", note the trailing
"/"
. The expectation is that when clients interact with the endpoint it will be in the form/prefix/'msgId'
-
getConnection
public AdaptrisConnection getConnection()
The underlying Jetty connection.
-
setConnection
public void setConnection(AdaptrisConnection connection)
The underlying Jetty connection.
-
getReportBuilder
@NonNull public @NonNull ReportBuilder getReportBuilder()
How to build reports.
-
setReportBuilder
public void setReportBuilder(@NonNull @NonNull ReportBuilder reportBuilder)
How to build reports.
-
getRetryStore
@NonNull public @NonNull RetryStore getRetryStore()
Where messages are stored for retries.
-
setRetryStore
public void setRetryStore(@NonNull @NonNull RetryStore retryStore)
Where messages are stored for retries.
-
getRetryHttpMethod
public java.lang.String getRetryHttpMethod()
The HTTP method which is required for retries; the default is POST.
-
setRetryHttpMethod
public void setRetryHttpMethod(java.lang.String retryHttpMethod)
The HTTP method which is required for retries; the default is POST.
-
getDeleteHttpMethod
public java.lang.String getDeleteHttpMethod()
The HTTP method which is required for deleting messages from the retry store; the default is DELETE.
-
setDeleteHttpMethod
public void setDeleteHttpMethod(java.lang.String deleteHttpMethod)
The HTTP method which is required for deleting messages from the retry store; the default is DELETE.
-
-