public interface LRAClient
| Modifier and Type | Field and Description |
|---|---|
static String |
LRA_COORDINATOR_HOST_KEY
Key for looking up the config property that specifies which host a
coordinator is running on
|
static String |
LRA_COORDINATOR_PATH_KEY
Key for looking up the config property that specifies which JAX-RS path a
coordinator is running on
|
static String |
LRA_COORDINATOR_PORT_KEY
Key for looking up the config property that specifies which port a
coordinator is running on
|
static String |
LRA_HTTP_HEADER
the name of the HTTP header field that contains the LRA id associated with
a request/response
|
static String |
LRA_HTTP_RECOVERY_HEADER
the name of the HTTP header field that contains a recovery URL corresponding
to a participant
enlistment in an LRA
updateCompensator(java.net.URL, java.net.URL, java.net.URL, java.net.URL, java.net.URL, java.lang.String) |
static String |
LRA_RECOVERY_HOST_KEY
Key for looking up the config property that specifies which JAX-RS path a
recovery coordinator is running on
|
static String |
LRA_RECOVERY_PATH_KEY
Key for looking up the config property that specifies which JAX-RS path a
recovery coordinator is running on
|
static String |
LRA_RECOVERY_PORT_KEY
Key for looking up the config property that specifies which JAX-RS path a
recovery coordinator is running on
|
| Modifier and Type | Method and Description |
|---|---|
String |
cancelLRA(URL lraId)
Attempt to cancel an LRA
Trigger compensation of all participants enlisted with the LRA (ie the
compensate message will be sent to each participant).
|
void |
close()
Explicitly dispose of all resources.
|
String |
closeLRA(URL lraId)
Attempt to close an LRA
Tells the LRA to close normally.
|
List<LRAInfo> |
getActiveLRAs()
Lookup active LRAs
|
List<LRAInfo> |
getAllLRAs()
Returns all (both active and recovering) LRAs
|
URL |
getCurrent()
checks whether there is an LRA associated with the calling thread
(this method provides an alternative to relying on the presence
of the
LRA_HTTP_HEADER HTTP header fields since
not all users of the API are being called in the context of JAX-RS
resource requests). |
List<LRAInfo> |
getRecoveringLRAs()
List recovering Long Running Actions
|
Optional<CompensatorStatus> |
getStatus(URL lraId)
Lookup the status of an LRA
|
Boolean |
isActiveLRA(URL lraId)
Indicates whether an LRA is active.
|
Boolean |
isCompensatedLRA(URL lraId)
Indicates whether an LRA was compensated.
|
Boolean |
isCompletedLRA(URL lraId)
Indicates whether an LRA is complete.
|
String |
joinLRA(URL lraId,
Class<?> resourceClass,
URI baseUri,
String compensatorData)
Join an LRA passing in a class that will act as the participant.
|
String |
joinLRA(URL lraId,
Long timelimit,
URL compensateUrl,
URL completeUrl,
URL forgetUrl,
URL leaveUrl,
URL statusUrl,
String compensatorData)
A participant can join with the LRA at any time prior to the completion of
an activity.
|
void |
leaveLRA(URL lraId,
String body)
A Compensator can resign from the LRA at any time prior to the completion
of an activity
|
void |
renewTimeLimit(URL lraId,
long limit,
TimeUnit unit)
LRAs can be created with timeouts after which they are cancelled.
|
void |
setCoordinatorURI(URI uri)
Set the endpoint on which the coordinator is available
|
void |
setCurrentLRA(URL lraId)
Update the clients notion of the current coordinator.
|
void |
setRecoveryCoordinatorURI(URI uri)
Set the endpoint on which the recovery coordinator is available
|
URL |
startLRA(String clientID,
Long timeout,
TimeUnit unit)
Start a top level LRA (ie similar to
startLRA(URL, String, Long, TimeUnit) |
URL |
startLRA(URL parentLRA,
String clientID,
Long timeout,
TimeUnit unit)
Start a new LRA
If the LRA was started during a JAX-RS resource method invocation then the
id of the new LRA will be made available as the JAX-RS response header
LRA_HTTP_HEADER |
URL |
updateCompensator(URL recoveryUrl,
URL compensateUrl,
URL completeUrl,
URL forgetUrl,
URL statusUrl,
String compensatorData)
Change the endpoints that a participant can be contacted on.
|
static final String LRA_HTTP_HEADER
static final String LRA_HTTP_RECOVERY_HEADER
updateCompensator(java.net.URL, java.net.URL, java.net.URL, java.net.URL, java.net.URL, java.lang.String)static final String LRA_COORDINATOR_HOST_KEY
static final String LRA_COORDINATOR_PORT_KEY
static final String LRA_COORDINATOR_PATH_KEY
static final String LRA_RECOVERY_HOST_KEY
static final String LRA_RECOVERY_PORT_KEY
static final String LRA_RECOVERY_PATH_KEY
void setCoordinatorURI(URI uri)
uri - the url of the LRA coordinatorvoid setRecoveryCoordinatorURI(URI uri)
uri - the url of the LRA recovery coordinatorvoid close()
URL startLRA(URL parentLRA, String clientID, Long timeout, TimeUnit unit) throws GenericLRAException
LRA_HTTP_HEADERparentLRA - The parent of the LRA that is about to start. If null then
the new LRA will be top levelclientID - The client may provide a (preferably) unique identity which
will be reported back when the LRA is queried.timeout - Specifies the maximum time that the LRA will exist for. If the
LRA is terminated because of a timeout it will be cancelled.unit - Specifies the unit that the timeout is measured injavax.ws.rs.NotFoundException - if the parent LRA is known to no longer existGenericLRAException - a new LRA could not be started. The specific
reason is available in GenericLRAException.getStatusCode()URL startLRA(String clientID, Long timeout, TimeUnit unit) throws GenericLRAException
startLRA(URL, String, Long, TimeUnit)clientID - The client may provide a (preferably) unique identity which
will be reported back when the LRA is queried.timeout - Specifies the maximum time that the LRA will exist for. If the
LRA is terminated because of a timeout it will be cancelled.unit - Specifies the unit that the timeout is measured injavax.ws.rs.NotFoundException - if the parent LRA is known to no longer existGenericLRAException - a new LRA could not be started. The specific
reason is available in GenericLRAException.getStatusCode()String cancelLRA(URL lraId) throws GenericLRAException
lraId - The unique identifier of the LRA (required)
Enum.name(). If the final status is not returned the
client can still discover the final state using the
getStatus(URL) methodjavax.ws.rs.NotFoundException - if the LRA no longer existsGenericLRAException - Communication error (the reason is availalbe via
the GenericLRAException.getStatusCode() methodString closeLRA(URL lraId) throws GenericLRAException
lraId - The unique identifier of the LRA (required)
Enum.name(). If the final status is not returned the
client can still discover the final state using the
getStatus(URL) methodjavax.ws.rs.NotFoundException - if the LRA no longer existsGenericLRAException - Communication error (the reason is availalbe via
the GenericLRAException.getStatusCode() methodList<LRAInfo> getActiveLRAs() throws GenericLRAException
GenericLRAException - on errorList<LRAInfo> getAllLRAs() throws GenericLRAException
GenericLRAException - on errorList<LRAInfo> getRecoveringLRAs() throws GenericLRAException
GenericLRAException - on errorOptional<CompensatorStatus> getStatus(URL lraId) throws GenericLRAException
lraId - the LRA whose status is being requestedjavax.ws.rs.NotFoundException - if the LRA no longer existsGenericLRAException - if the request to the coordinator failed.
Throwable.getCause() and/or
GenericLRAException.getStatusCode()
may provide a more specific reason.Boolean isActiveLRA(URL lraId) throws GenericLRAException
getStatus(URL).lraId - The unique identifier of the LRA (required)javax.ws.rs.NotFoundException - if the LRA no longer existsGenericLRAException - if the request to the coordinator failed.
Throwable.getCause() and/or
GenericLRAException.getStatusCode()
may provide a more specific reason.Boolean isCompensatedLRA(URL lraId) throws GenericLRAException
getStatus(URL).lraId - The unique identifier of the LRA (required)javax.ws.rs.NotFoundException - if the LRA no longer existsGenericLRAException - if the request to the coordinator failed.
Throwable.getCause() and/or
GenericLRAException.getStatusCode()
may provide a more specific reason.Boolean isCompletedLRA(URL lraId) throws GenericLRAException
getStatus(URL).lraId - The unique identifier of the LRA (required)javax.ws.rs.NotFoundException - if the LRA no longer existsGenericLRAException - if the request to the coordinator failed.
Throwable.getCause() and/or
GenericLRAException.getStatusCode()
may provide a more specific reason.String joinLRA(URL lraId, Long timelimit, URL compensateUrl, URL completeUrl, URL forgetUrl, URL leaveUrl, URL statusUrl, String compensatorData) throws GenericLRAException
lraId - The unique identifier of the LRA (required) to enlist withtimelimit - The time limit (in seconds) that the participant can
guarantee that it can compensate the work performed while
the LRA is active.compensateUrl - the `compensatation URL`completeUrl - the `completion URL`forgetUrl - the `forget URL`leaveUrl - the `leave URL`statusUrl - the `status URL`compensatorData - data that will be stored with the coordinator and
passed back to the participant when the LRA is closed
or cancelledjavax.ws.rs.NotFoundException - if the LRA no longer existsGenericLRAException - if the request to the coordinator failed.
Throwable.getCause() and/or
GenericLRAException.getStatusCode()
may provide a more specific reason.String joinLRA(URL lraId, Class<?> resourceClass, URI baseUri, String compensatorData) throws GenericLRAException
joinLRA(URL, Class, URI, String) except
that the various participant URLs are expressed as CDI annotations on
the passed in resource class.lraId - The unique identifier of the LRA (required)resourceClass - An annotated class for the participant methods:
Compensate, etc.baseUri - Base uri for the participant endpointscompensatorData - Compensator specific data that the coordinator will
pass to the participant when the LRA is closed or
cancelledjavax.ws.rs.NotFoundException - if the LRA no longer existsGenericLRAException - if the request to the coordinator failed.
Throwable.getCause() and/or
GenericLRAException.getStatusCode() may provide a more specific reason.URL updateCompensator(URL recoveryUrl, URL compensateUrl, URL completeUrl, URL forgetUrl, URL statusUrl, String compensatorData) throws GenericLRAException
recoveryUrl - the recovery URL returned from a participant join requestcompensateUrl - the URL to invoke when the LRA is cancelledcompleteUrl - the URL to invoke when the LRA is closedstatusUrl - if a participant cannot finish immediately then it provides
this URL that the coordinator uses to monitor the progressforgetUrl - used to inform the participant that can forget about this LRAcompensatorData - opaque data that returned to the participant when the
LRA is closed or cancelledGenericLRAException - if the request to the coordinator failed.
Throwable.getCause() and/or
GenericLRAException.getStatusCode() may provide a more specific reason.void leaveLRA(URL lraId, String body) throws GenericLRAException
lraId - The unique identifier of the LRA (required)body - (optional)javax.ws.rs.NotFoundException - if the LRA no longer existsjavax.ws.rs.NotFoundException - if the LRA no longer existsGenericLRAException - if the request to the coordinator failed.
Throwable.getCause() and/or
GenericLRAException.getStatusCode() may provide a more specific reason.void renewTimeLimit(URL lraId, long limit, TimeUnit unit)
lraId - the id of the lra to updatelimit - the new timeout periodunit - the time unit for limitjavax.ws.rs.NotFoundException - if the LRA no longer existsURL getCurrent()
LRA_HTTP_HEADER HTTP header fields since
not all users of the API are being called in the context of JAX-RS
resource requests).void setCurrentLRA(URL lraId)
lraId - the id of the LRA (can be null)javax.ws.rs.NotFoundException - if the LRA no longer existsCopyright © 2018 Eclipse Foundation. All rights reserved.