@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 storeWhile 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.
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.
Modifier and Type | Field and 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 and Description |
---|
RetryFromJetty() |
Modifier and Type | Method and 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 component
|
RetryFromJetty |
withReportBuilder(ReportBuilder b) |
RetryFromJetty |
withRetryStore(RetryStore rs) |
addWorkflow, clearWorkflows, getUniqueId, getWorkflow, getWorkflow, getWorkflows, registeredWorkflowIds, setUniqueId, updateRetryCountMetadata
public static final java.lang.String DEFAULT_ENDPOINT_PREFIX
public static final java.lang.String DEFAULT_REPORTING_ENDPOINT
public static final java.lang.String DEFAULT_DELETE_PREFIX
public static final java.lang.String CONTENT_TYPE_METADATA_KEY
public static final java.lang.String CONTENT_TYPE_EXPR
protected static final java.lang.String HTTP_OK
protected static final java.lang.String HTTP_ACCEPTED
protected static final java.lang.String HTTP_ERROR
protected static final java.lang.String HTTP_BAD
protected static final java.lang.String HTTP_NOT_FOUND
public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
CoreException
- wrapping any underlying Exception
spublic void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
CoreException
- wrapping any underlying Exception
spublic void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
public void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException
may
cause unintended consequences
public RetryFromJetty withRetryStore(RetryStore rs)
public RetryFromJetty withReportBuilder(ReportBuilder b)
protected static void executeQuietly(Service service, AdaptrisMessage msg)
public java.lang.String getRetryEndpointPrefix()
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'
public void setRetryEndpointPrefix(java.lang.String retryEndpointPrefix)
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'
public java.lang.String getReportingEndpoint()
The default if not explicitly specified is "/api/failed/list".
public void setReportingEndpoint(java.lang.String reportingEndpoint)
The default if not explicitly specified is "/api/failed/list".
public java.lang.String getDeleteEndpointPrefix()
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'
public void setDeleteEndpointPrefix(java.lang.String deleteEndpointPrefix)
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'
public AdaptrisConnection getConnection()
public void setConnection(AdaptrisConnection connection)
@NonNull public @NonNull ReportBuilder getReportBuilder()
public void setReportBuilder(@NonNull @NonNull ReportBuilder reportBuilder)
@NonNull public @NonNull RetryStore getRetryStore()
public void setRetryStore(@NonNull @NonNull RetryStore retryStore)
public java.lang.String getRetryHttpMethod()
public void setRetryHttpMethod(java.lang.String retryHttpMethod)
public java.lang.String getDeleteHttpMethod()
public void setDeleteHttpMethod(java.lang.String deleteHttpMethod)