Search in sources :

Example 1 with LRARecord

use of io.narayana.lra.coordinator.domain.model.LRARecord in project narayana by jbosstm.

the class LRAService method joinLRA.

public synchronized int joinLRA(StringBuilder recoveryUrl, URL lra, long timeLimit, String compensatorUrl, String linkHeader, String recoveryUrlBase, String compensatorData) {
    if (lra == null)
        lraTrace(null, "Error missing LRA header in join request");
    lraTrace(lra, "join LRA");
    Transaction transaction = getTransaction(lra);
    if (timeLimit < 0)
        timeLimit = 0;
    if (!transaction.isActive())
        return Response.Status.PRECONDITION_FAILED.getStatusCode();
    LRARecord participant;
    try {
        participant = transaction.enlistParticipant(lra, linkHeader != null ? linkHeader : compensatorUrl, recoveryUrlBase, timeLimit, compensatorData);
    } catch (UnsupportedEncodingException e) {
        return Response.Status.PRECONDITION_FAILED.getStatusCode();
    }
    if (// probably already closing or cancelling
    participant == null || participant.getRecoveryCoordinatorURL() == null)
        return Response.Status.PRECONDITION_FAILED.getStatusCode();
    String recoveryURL = participant.getRecoveryCoordinatorURL().toExternalForm();
    updateRecoveryURL(lra, participant.getParticipantURL(), recoveryURL, false);
    recoveryUrl.append(recoveryURL);
    return Response.Status.OK.getStatusCode();
}
Also used : Transaction(io.narayana.lra.coordinator.domain.model.Transaction) UnsupportedEncodingException(java.io.UnsupportedEncodingException) LRARecord(io.narayana.lra.coordinator.domain.model.LRARecord)

Aggregations

LRARecord (io.narayana.lra.coordinator.domain.model.LRARecord)1 Transaction (io.narayana.lra.coordinator.domain.model.Transaction)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1