Interface FaultToleranceMethodContext
-
- All Known Implementing Classes:
FaultToleranceMethodContextImpl
public interface FaultToleranceMethodContext
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
FaultToleranceMethodContext.AsyncFuture
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FaultToleranceMethodContext
boundTo(jakarta.interceptor.InvocationContext context, FaultTolerancePolicy policy)
void
delay(long delayMillis)
Delays the current thread by the given duration.void
endTrace()
Ends the innermost trace.Object
fallbackHandle(Class<? extends org.eclipse.microprofile.faulttolerance.FallbackHandler<?>> fallbackClass, Throwable ex)
Object
fallbackInvoke(Method fallbackMethod)
Invokes the given fallbackMethod
in the given context.BlockingQueue<Thread>
getConcurrentExecutions()
Get or create theBlockingQueue
for bulkhead.FaultToleranceMetrics
getMetrics()
Returns theFaultToleranceMetrics
to use.AtomicInteger
getQueuingOrRunningPopulation()
Get the bulkhead thread count.CircuitBreakerState
getState()
Get or create theCircuitBreakerState
.Object
proceed()
Proceeds execution to the annotated method body.void
runAsynchronous(FaultToleranceMethodContext.AsyncFuture asyncResult, Callable<Object> task)
Runs the task asynchronously and completes the given asyncResult with the its outcome.Future<?>
runDelayed(long delayMillis, Runnable task)
Runs a given task after a certain waiting time.void
trace(String method)
Starts tracing the given context named with the given method label.
-
-
-
Method Detail
-
boundTo
FaultToleranceMethodContext boundTo(jakarta.interceptor.InvocationContext context, FaultTolerancePolicy policy)
-
getMetrics
FaultToleranceMetrics getMetrics()
Returns theFaultToleranceMetrics
to use.- Returns:
- the
FaultToleranceMetrics
to use,FaultToleranceMetrics.DISABLED
when not enabled.
-
getState
CircuitBreakerState getState()
Get or create theCircuitBreakerState
.- Returns:
- the created or existing state, or null if non existed and requestVolumeThreshold was null
-
getConcurrentExecutions
BlockingQueue<Thread> getConcurrentExecutions()
Get or create theBlockingQueue
for bulkhead.- Returns:
- the created or existing queue, or null if non existed and requestVolumeThreshold was null
-
getQueuingOrRunningPopulation
AtomicInteger getQueuingOrRunningPopulation()
Get the bulkhead thread count.- Returns:
- This are number of threads that are either waiting or running in the bulkhead.
-
delay
void delay(long delayMillis) throws InterruptedException
Delays the current thread by the given duration. The delay is traced.- Parameters:
delayMillis
- the time to sleep in millisecondscontext
- current context delayed- Throws:
InterruptedException
- In case waiting is interrupted
-
runDelayed
Future<?> runDelayed(long delayMillis, Runnable task) throws Exception
Runs a given task after a certain waiting time.- Parameters:
delayMillis
- time to wait in milliseconds before running the given tasktask
- operation to run- Returns:
- A future that can be cancelled if the operation should no longer be run
- Throws:
Exception
-
runAsynchronous
void runAsynchronous(FaultToleranceMethodContext.AsyncFuture asyncResult, Callable<Object> task) throws RejectedExecutionException
Runs the task asynchronously and completes the given asyncResult with the its outcome.- Parameters:
asyncResult
- a not yet completedCompletableFuture
that should receive the result of the operation when it is executedcontext
- the currently processed context (for e.g. tracing)task
- an operation that must compute a value of typeFuture
orCompletionStage
.- Throws:
RejectedExecutionException
- In case the task could not be accepted for execution. Usually due to too many work in progress.
-
fallbackHandle
Object fallbackHandle(Class<? extends org.eclipse.microprofile.faulttolerance.FallbackHandler<?>> fallbackClass, Throwable ex) throws Exception
Invokes the instance of the givenFallbackHandler
Class
defined in the given context to handle the givenException
.- Parameters:
fallbackClass
- the type ofFallbackHandler
to resolve or instantiate and usecontext
- the currently processed context to use for argumentsex
- theException
thrown by the FT processing to handle by theFallbackHandler
- Returns:
- the result returned by the invoked
FallbackHandler
- Throws:
Exception
- in case resolving, instantiating or invoking the handler method fails
-
fallbackInvoke
Object fallbackInvoke(Method fallbackMethod) throws Exception
Invokes the given fallbackMethod
in the given context.
-
trace
void trace(String method)
Starts tracing the given context named with the given method label.- Parameters:
method
- the label to use for the tracecontext
- the currently processed context
-
endTrace
void endTrace()
Ends the innermost trace.
-
-