org.eclipse.microprofile.lra.tck.service.spi

## Interface LRARecoveryService

    public interface LRARecoveryService

The LRA model guarantees eventual consistency but does not say when participants will be brought into a consistent state. When a request to close/cancel an LRA is received, the implementation is allowed to delay sending out the complete/compensate callbacks (the specification only requires that an implementation must eventually send them). This SPI provides a mechanism for an implementation to indicate when it knows that callbacks have been sent and responses received or when callbacks have been issued, all participants have reached an end state, and when all listener notifications have been successfully delivered.

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods
`void` `waitForCallbacks(URI lraId)` Wait for the delivery of Complete and Compensate participant callbacks.
`boolean` `waitForEndPhaseReplay(URI lraId)` Wait for one replay of the end phase of the LRA (the callback calls to Status, Complete, Compensate, and Forget methods of all Compensating/Completing participants.
`default void` `waitForRecovery(URI lraId)` Wait for all participants to reach an end state and for all `AfterLRA` notifications to be successfully delivered (AfterLRA methods return HTTP 200).

### Method Detail

#### waitForCallbacks

    void waitForCallbacks(URI lraId)
                   throws LRACallbackException

Wait for the delivery of Complete and Compensate participant callbacks. When this method returns the caller can be certain that the callbacks were sent and responses received (including error responses).

Parameters:
  `lraId` - the LRA context
Throws:
  `LRACallbackException` - the implementation was unable to determine whether or not the callbacks were received by all participants

#### waitForRecovery

    default void waitForRecovery(URI lraId)
                          throws LRACallbackException

Wait for all participants to reach an end state and for all `AfterLRA` notifications to be successfully delivered (AfterLRA methods return HTTP 200). The default implementation iterates `waitForEndPhaseReplay(URI)` until all participants reach a final state and all AfterLRA listeners notifications are successfully delivered.

Parameters:
  `lraId` - the LRA context
Throws:
  `LRACallbackException` - the implementation was unable to determine whether or not all participants have reached an end state and whether or not all listeners have been successfully notified

#### waitForEndPhaseReplay

    boolean waitForEndPhaseReplay(URI lraId)
                           throws LRACallbackException

Wait for one replay of the end phase of the LRA (the callback calls to Status, Complete, Compensate, and Forget methods of all Compensating/Completing participants. If the LRA is finished as a result of this call all listeners must also be successfully notified before this method returns. The callback calls must be attempted but do not have to be successful (e.g. implementation tries to call Compensate which returns connection refused is a valid invocation of this method).

Parameters:
  `lraId` - the LRA context
Returns:
  true if the implementation successfully issued callback requests and received responses that indicate that final state was achieved and all AfterLRA listeners were successfully notified (AfterLRA methods returned HTTP 200), or false if the implementation successfully issued callback requests but it did not receive all responses or the received responses indicate that the final state is not reached yet
Throws:
  `LRACallbackException` - the implementation has no knowledge of this LRA or it was unable to retry the requests to all participants so it does not make sense to trigger this method with the same argument again