@Retention(value=RUNTIME) @Target(value=METHOD) public @interface AfterLRA
If a JAX-RS resource method is annotated with
LRA
and is invoked in the context of an LRA then
the resource can ask to be notified when the LRA finishes
by marking one of the other methods in the class with
the @AfterLRA
annotation.
The listener can register interest in the final outcome of an LRA at
any time up until the LRA has reached a final state. In other words,
if an LRA is closing or cancelling then listener registrations
should be allowed. This is in contrast to registering for participant
callbacks which are only allowed if the LRA is active.
A consequence of this statement is that if a class is annotated with
both the AfterLRA
and the Compensate
annotations and the LRA has
already started closing or cancelling then the LRA
method invocation
will fail with a 412 Precondition Failed
JAX-RS response
code because the Compensate
method requires LRA to be Active. Without
the Compensate
method present, the after LRA listener would be registered successfully.
If the AfterLRA
method is also a JAX-RS resource method
then it MUST use the PUT
request method. In this
case, the LRA context is made available to the annotated method
via an HTTP header with the name
LRA.LRA_HTTP_ENDED_CONTEXT_HEADER
and the
final status is passed to the method as plain text
corresponding to one of the LRAStatus
enum values.
If this LRA was nested then the parent LRA MUST be present in the header
LRA.LRA_HTTP_PARENT_CONTEXT_HEADER
and value is of type URI
. For example:
@PUT
@AfterLRA
public Response afterEnd(@HeaderParam(LRA_HTTP_ENDED_CONTEXT_HEADER) URI lraId,
@HeaderParam(LRA_HTTP_PARENT_CONTEXT_HEADER) URI parentLraId,
Status status)
The implementation SHOULD keep resending the notification
until it receives a 200 OK
status code from the
resource method (which means that the method SHOULD be
idempotent).
If it stops retrying a warning message SHOULD be logged.
If the AfterLRA
method is not a JAX-RS resource method
then the id of the LRA and its final status can be obtained
by ensuring that the annotated method conforms to the
signature:
public void onLRAEnd(URI lraId, LRAStatus status)
The return type is ignored and the method name is not significant.
Copyright © 2018 – 2021 Eclipse Foundation. All rights reserved.
Use is subject to license terms.