Enum LRA.Type
- All Implemented Interfaces:
Serializable,Comparable<LRA.Type>
- Enclosing class:
- LRA
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionIf called outside an LRA context the method is not executed and a412 Precondition FailedHTTP status code is returned to the caller.An LRA (called the child) can be scoped within an existing LRA (called the parent) using the NESTED element value.If called outside an LRA context, i.e.,LRA.LRA_HTTP_CONTEXT_HEADERis not present, the resource method execution must then continue outside an LRA context.The resource method is executed without an LRA context.If called outside an LRA context the invoked method will run with a new context.If called outside an LRA context the invoked method will run with a new context.If called outside an LRA context the resource method execution must then continue outside an LRA context. -
Method Summary
-
Enum Constant Details
-
REQUIRED
If called outside an LRA context the invoked method will run with a new context.
If called inside an LRA context the invoked method will run with the same context.
-
REQUIRES_NEW
If called outside an LRA context the invoked method will run with a new context.
If called inside an LRA context the invoked method will run with a new context. The original context is ignored.
-
MANDATORY
If called outside an LRA context the method is not executed and a
412 Precondition FailedHTTP status code is returned to the caller.If called inside a transaction context the resource method execution will then continue within that context.
-
SUPPORTS
If called outside an LRA context the resource method execution must then continue outside an LRA context.
If called inside an LRA context the resource method execution must then continue with the same LRA context.
-
NOT_SUPPORTED
The resource method is executed without an LRA context.
-
NEVER
If called outside an LRA context, i.e.,
LRA.LRA_HTTP_CONTEXT_HEADERis not present, the resource method execution must then continue outside an LRA context.If called inside an LRA context, i.e.,
LRA.LRA_HTTP_CONTEXT_HEADERis present referring to an active, inactive or non-existent LRA, the method is not executed and a412 Precondition FailedHTTP status code is returned to the caller. -
NESTED
An LRA (called the child) can be scoped within an existing LRA (called the parent) using the NESTED element value. A new LRA will be created even if there is already one present when the method is invoked, i.e., these LRAs will then either be top-level or nested automatically depending upon the context within which they are created. If invoked without a context, the new LRA will be top level. If invoked with an LRA present, a new nested LRA is started whose outcome depends upon whether or not the enclosing LRA is closed or cancelled. The id of the parent LRA MUST be present in the header with the name "Long-Running-Action-Parent" and the value is of type
URI.A nested LRA is treated just like any other LRA with respect to participant enlistment. When an invocation results in the creation of a nested LRA that LRA becomes the "current context" and any further operations performed by the method will be executed with that context. The semantics of nested LRAs follows previous transactions models:
- A nested LRA can close or cancel independently of its parent.
- A nested LRA which has closed must retain the ability to cancel the effects if the the parent cancels. This requirement must be enforced by participants.
- If a nested LRA cancels then all of its children must effectively cancel (even if they have previously been asked to close - see 2)
- If a nested LRA closes then it, and all of its children, must close (but retain the ability to later cancel - see 2).
Downstream LRAs will only be part of this nesting hierarchy if the downstream methods carry the NESTED element, otherwise they are independent of the current nested LRA.
The reason why the model does not allow a cancelled nested LRA to be closed is because the business activity has already been compensated for which means there is no longer any outstanding work in need of completion.
On the other hand it does make sense to cancel the effects of a closed nested LRA since the work has been done and there is something that can be compensated for. In this case the LRA method invocation is allowed to proceed only if the participant is already enlisted with the LRA, otherwise the method invocation is rejected using a
412 Precondition FailedHTTP status code. If the method invocation causes the LRA to close then theCompleteannotated method, if present, is not called again. If the LRA method causes the LRA to cancel then the nested LRA is moved to theLRAStatus.Cancellingstate and theCompensatecallback will be invoked.Therefore, as a consequence of requirement 2, any activities performed in the context of a closed nested LRA must remain compensatable until the top level parent LRA finishes. So if the nested LRA is closed the participants registered with it will be asked to complete, but if the top level parent LRA is then told to cancel the nested participants will be told to compensate. This implies that the nested participants must be aware that they are nested and the JAX-RS header with the name "Long-Running-Action-Parent" is guaranteed to hold the parent context whenever a nested LRA is being propagated.
A participant which has completed can determine when the top level parent has closed by providing a
Forgetcallback handler. When this method is called there is no longer a requirement to maintain the ability to reverse the effects of a closed nested LRA. This can be used by the participant to clean up any resources it used to implement this guarantee.Note that it is possible for the same resource to be registered with both the parent and the child LRAs and in this case it will be asked to complete or compensate twice, once with the nested context and a second time with the parent context. The order in which the two callbacks are invoked is undefined.
Note that the elements of the LRA annotation always apply to the LRA context used to execute the annotated method. Thus elements such as
LRA.timeLimit(),LRA.timeUnit(),LRA.cancelOn(),LRA.cancelOnFamily()andLRA.end()will always be applied to the nested or top level LRA.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-