Class UnitOfWorkTimeoutInterceptorBuilder
java.lang.Object
org.axonframework.messaging.core.timeout.UnitOfWorkTimeoutInterceptorBuilder
Message handler interceptor that sets a timeout on the processing of the current
ProcessingContext. If the
timeout is reached, the thread is interrupted and the transaction will be rolled back automatically.
Note: Due to interceptor ordering, this interceptor may not be the first in the chain. We are unable to work around
this, and as such the timeout measuring starts from the moment this interceptor is invoked, and ends measuring when
the commit of the ProcessingContext is completed.
- Since:
- 4.11.0
- Author:
- Mitchell Herrijgers
-
Constructor Summary
ConstructorsConstructorDescriptionUnitOfWorkTimeoutInterceptorBuilder(String componentName, int timeout, int warningThreshold, int warningInterval) Creates a newUnitOfWorkTimeoutInterceptorfor the givencomponentNamewith the giventimeout,warningThresholdandwarningInterval.UnitOfWorkTimeoutInterceptorBuilder(String componentName, int timeout, int warningThreshold, int warningInterval, ScheduledExecutorService executorService, org.slf4j.Logger logger) Creates a newUnitOfWorkTimeoutInterceptorfor the givencomponentNamewith the giventimeout,warningThresholdandwarningInterval. -
Method Summary
Modifier and TypeMethodDescriptionConstructs aCommandMessagehandler interceptor, to be registered on (e.g.) theCommandBus.Constructs aEventMessagehandler interceptor, to be registered on (e.g.) theEventProcessorConfiguration.Constructs aQueryMessagehandler interceptor, to be registered on (e.g.) theQueryBus.
-
Constructor Details
-
UnitOfWorkTimeoutInterceptorBuilder
public UnitOfWorkTimeoutInterceptorBuilder(String componentName, int timeout, int warningThreshold, int warningInterval) Creates a newUnitOfWorkTimeoutInterceptorfor the givencomponentNamewith the giventimeout,warningThresholdandwarningInterval. The warnings and timeout will be scheduled on theAxonTaskJanitor.INSTANCE. If you want to use a differentScheduledExecutorServiceorLoggerto log on, use the otherUnitOfWorkTimeoutInterceptorBuilder(String, int, int, int, ScheduledExecutorService, Logger).- Parameters:
componentName- The name of the component to be included in the loggingtimeout- The timeout in millisecondswarningThreshold- The threshold in milliseconds after which a warning is logged. Setting this to a value higher thantimeoutwill disable warnings.warningInterval- The interval in milliseconds between warnings.
-
UnitOfWorkTimeoutInterceptorBuilder
public UnitOfWorkTimeoutInterceptorBuilder(String componentName, int timeout, int warningThreshold, int warningInterval, ScheduledExecutorService executorService, org.slf4j.Logger logger) Creates a newUnitOfWorkTimeoutInterceptorfor the givencomponentNamewith the giventimeout,warningThresholdandwarningInterval. The warnings and timeout will be scheduled on the providedexecutorService.- Parameters:
componentName- The name of the component to be included in the loggingtimeout- The timeout in millisecondswarningThreshold- The threshold in milliseconds after which a warning is logged. Setting this to a value higher thantimeoutwill disable warnings.warningInterval- The interval in milliseconds between warnings.executorService- The executor service to schedule the timeout and warningslogger- The logger to log warnings and errors
-
-
Method Details
-
buildCommandInterceptor
Constructs aCommandMessagehandler interceptor, to be registered on (e.g.) theCommandBus.- Returns:
- A
CommandMessagehandler interceptor, to be registered on (e.g.) theCommandBus.
-
buildEventInterceptor
Constructs aEventMessagehandler interceptor, to be registered on (e.g.) theEventProcessorConfiguration.- Returns:
- A
EventMessagehandler interceptor, to be registered on (e.g.) theEventProcessorConfiguration.
-
buildQueryInterceptor
Constructs aQueryMessagehandler interceptor, to be registered on (e.g.) theQueryBus.- Returns:
- A
QueryMessagehandler interceptor, to be registered on (e.g.) theQueryBus.
-