@RequestScoped public class SRAClient extends Object implements SRAClientAPI, Closeable
org.jboss.jbossts.star.annotation package| Modifier and Type | Field and Description |
|---|---|
static String |
CLIENT_ID_PARAM_NAME |
static String |
COMMIT |
static String |
COORDINATOR_URL_PROP |
static long |
DEFAULT_TIMEOUT_MILLIS |
static String |
ONEPHASECOMMIT |
static String |
PARENT_SRA_PARAM_NAME |
static String |
PREPARE |
static String |
ROLLBACK |
static String |
RTS_HTTP_CONTEXT_HEADER |
static String |
RTS_HTTP_RECOVERY_HEADER |
static String |
STATUS |
static String |
TIMELIMIT_PARAM_NAME |
static String |
TX_COMMITTED |
static String |
TX_ROLLBACK_ONLY |
static String |
TX_ROLLEDBACK |
| Constructor and Description |
|---|
SRAClient() |
| Modifier and Type | Method and Description |
|---|---|
String |
cancelSRA(URL sraId)
Attempt to cancel an SRA
Trigger the compensation of the SRA.
|
void |
close() |
String |
commitSRA(URL sraId)
Attempt to close an SRA
Trigger the successful completion of the SRA.
|
static String |
encodeURL(URL sraId,
String message) |
List<SRAInfo> |
getActiveSRAs()
Lookup active SRAs
|
List<SRAInfo> |
getAllSRAs()
Returns all SRAs
Gets both active and recovering SRAs
|
URL |
getCurrent()
checks whether there is an SRA associated with the calling thread
|
List<SRAInfo> |
getRecoveringSRAs()
List recovering Long Running Actions
Returns SRAs that are recovering (ie some compensators still need to be ran)
|
List<String> |
getResponseData(URL sraId) |
static String |
getSRAId(String sraId) |
Map<String,String> |
getTerminationUris(URL aaId,
Class<?> compensatorClass,
javax.ws.rs.core.UriInfo uriInfo,
boolean validate) |
String |
getUrl() |
Boolean |
isActiveSRA(URL sraId)
Indicates whether an SRA is active
|
Boolean |
isCompensatedSRA(URL sraId)
Indicates whether an SRA was compensated
|
Boolean |
isCompletedSRA(URL sraId)
Indicates whether an SRA is complete
|
void |
joinSRA(URL sraId,
Long timelimit,
String compensatorUrl)
A SRAParticipant can join with the SRA at any time prior to the completion of an activity
|
String |
joinSRA(URL sraId,
Long timelimit,
String compensateUrl,
String completeUrl,
String leaveUrl,
String statusUrl)
Similar to
SRAClientAPI.joinSRA(URL, Long, String) but the various compensator urls
are passed in explicitly |
String |
joinSRAWithLinkHeader(URL sraUrl,
Long timelimit,
String linkHeader) |
void |
postConstruct() |
void |
setCurrentSRA(URL coordinatorUrl)
Update the clients notion of the current coordinator.
|
static URL |
sraToURL(String sraId) |
static URL |
sraToURL(String sraId,
String message) |
URL |
startSRA(String clientID,
Long timeout) |
URL |
startSRA(URL parentSRA,
String clientID,
Long timeout,
TimeUnit unit) |
static String |
stripUid(URL url) |
URL |
toURL(String sraId) |
public static final String RTS_HTTP_CONTEXT_HEADER
public static final String RTS_HTTP_RECOVERY_HEADER
public static final String COORDINATOR_URL_PROP
public static final String COMMIT
public static final String PREPARE
public static final String ROLLBACK
public static final String STATUS
public static final String ONEPHASECOMMIT
public static final String TIMELIMIT_PARAM_NAME
public static final String CLIENT_ID_PARAM_NAME
public static final String PARENT_SRA_PARAM_NAME
public static final long DEFAULT_TIMEOUT_MILLIS
public static final String TX_COMMITTED
public static final String TX_ROLLEDBACK
public static final String TX_ROLLBACK_ONLY
public SRAClient()
throws URISyntaxException,
MalformedURLException
@PostConstruct public void postConstruct()
public URL toURL(String sraId) throws InvalidSRAId
InvalidSRAIdpublic void setCurrentSRA(URL coordinatorUrl)
coordinatorUrl - the full url of an SRApublic URL startSRA(String clientID, Long timeout) throws GenericSRAException
GenericSRAExceptionpublic URL startSRA(URL parentSRA, String clientID, Long timeout, TimeUnit unit) throws GenericSRAException
startSRA in interface SRAClientAPIparentSRA - the parent SRA if this new SRA is nestedclientID - Each client is expected to have a unique identity (which can be a URL). (optional)timeout - Specifies the maximum time in seconds that the SRA will exist for. If the SRA is
terminated because of a timeout, the SRA URL is deleted. All further invocations
on the URL will return 404. The invoker can assume this was equivalent to a compensate
operation. (optional, default to 0)GenericSRAExceptionpublic String cancelSRA(URL sraId) throws GenericSRAException
SRAClientAPIcancelSRA in interface SRAClientAPIsraId - The unique identifier of the SRA (required)GenericSRAException - Comms errorpublic String commitSRA(URL sraId) throws GenericSRAException
SRAClientAPIcommitSRA in interface SRAClientAPIsraId - The unique identifier of the SRA (required)GenericSRAException - Comms errorpublic String joinSRAWithLinkHeader(URL sraUrl, Long timelimit, String linkHeader) throws GenericSRAException
sraUrl - the URL of the SRA to jointimelimit - how long the io.narayana.sra is prepared to wait for SRA completionlinkHeader - io.narayana.sra protocol URLs in link header format (RFC 5988)GenericSRAException - if the SRA coordinator failed to enlist the io.narayana.srapublic void joinSRA(URL sraId, Long timelimit, String compensatorUrl) throws GenericSRAException
SRAClientAPIjoinSRA in interface SRAClientAPIsraId - The unique identifier of the SRA (required)timelimit - The time limit (in seconds) that the SRAParticipant can guarantee that it
can compensate the work performed by the io.narayana.sra.demo.service. After this time period has elapsed,
it may no longer be possible to undo the work within the scope of this (or any enclosing)
SRA. It may therefore be necessary for the application or io.narayana.sra.demo.service to start other
activities to explicitly try to compensate this work. The application or coordinator may
use this information to control the lifecycle of a SRA. (required)compensatorUrl - The resource path that the SRA coordinator will use to drive the compensator.
Performing a GET on the compensator URL will return the current status of the compensator,
or 404 if the compensator is no longer present. The following types must be returned by
Compensators to indicate their current status:
- Compensating: the SRAParticipant is currently compensating for the SRA;
- Compensated: the SRAParticipant has successfully compensated for
the SRA.
- FailedToCompensate: the SRAParticipant was not able to compensate for the SRA.
It must maintain information about the work it was to compensate until the
coordinator sends it a forget message.
- Completing: the SRAParticipant is tidying up after being told to complete.
- Completed: the coordinator/io.narayana.sra has confirmed.
- FailedToComplete: the SRAParticipant was unable to tidy-up.
Performing a POST on URL/compensate will cause the compensator to compensate
the work that was done within the scope of the SRA.
Performing a POST on URL/complete will cause the compensator to tidy up and
it can forget this SRA. (optional)GenericSRAException - Comms errorpublic String joinSRA(URL sraId, Long timelimit, String compensateUrl, String completeUrl, String leaveUrl, String statusUrl) throws GenericSRAException
SRAClientAPISRAClientAPI.joinSRA(URL, Long, String) but the various compensator urls
are passed in explicitlyjoinSRA in interface SRAClientAPIsraId - The unique identifier of the SRA (required)timelimit - The time limit (in seconds) that the SRAParticipant can guarantee that it
can compensate the work performed by the io.narayana.sra.demo.servicecompensateUrl - Performing a POST onthis URL will cause the io.narayana.sra to compensate the work that
was done within the scope of the SRA.completeUrl - Performing a POST on this URL will cause the io.narayana.sra to tidy up and it can forget this transaction.leaveUrl - Performing a PUT on this URL with cause the compensator to leave the SRAstatusUrl - Performing a GET on this URL will return the status of the compensator joinSRAGenericSRAExceptionpublic List<SRAInfo> getAllSRAs() throws GenericSRAException
SRAClientAPIgetAllSRAs in interface SRAClientAPIGenericSRAException - Comms errorpublic List<SRAInfo> getActiveSRAs() throws GenericSRAException
SRAClientAPIgetActiveSRAs in interface SRAClientAPIGenericSRAException - Comms errorpublic List<SRAInfo> getRecoveringSRAs() throws GenericSRAException
SRAClientAPIgetRecoveringSRAs in interface SRAClientAPIGenericSRAException - Comms errorpublic Boolean isActiveSRA(URL sraId) throws GenericSRAException
SRAClientAPIisActiveSRA in interface SRAClientAPIsraId - The unique identifier of the SRA (required)GenericSRAException - Comms errorpublic Boolean isCompensatedSRA(URL sraId) throws GenericSRAException
SRAClientAPIisCompensatedSRA in interface SRAClientAPIsraId - The unique identifier of the SRA (required)GenericSRAException - Comms errorpublic Boolean isCompletedSRA(URL sraId) throws GenericSRAException
SRAClientAPIisCompletedSRA in interface SRAClientAPIsraId - The unique identifier of the SRA (required)GenericSRAException - Comms errorpublic Map<String,String> getTerminationUris(URL aaId, Class<?> compensatorClass, javax.ws.rs.core.UriInfo uriInfo, boolean validate)
public String getUrl()
public URL getCurrent()
SRAClientAPIgetCurrent in interface SRAClientAPIpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic List<String> getResponseData(URL sraId)
getResponseData in interface SRAClientAPICopyright © 2021 JBoss by Red Hat. All rights reserved.