Class UnitOfWorkTimeoutInterceptorBuilder

java.lang.Object
org.axonframework.messaging.core.timeout.UnitOfWorkTimeoutInterceptorBuilder

public class UnitOfWorkTimeoutInterceptorBuilder extends Object
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 Details

    • UnitOfWorkTimeoutInterceptorBuilder

      public UnitOfWorkTimeoutInterceptorBuilder(String componentName, int timeout, int warningThreshold, int warningInterval)
      Creates a new UnitOfWorkTimeoutInterceptor for the given componentName with the given timeout, warningThreshold and warningInterval. The warnings and timeout will be scheduled on the AxonTaskJanitor.INSTANCE. If you want to use a different ScheduledExecutorService or Logger to log on, use the other UnitOfWorkTimeoutInterceptorBuilder(String, int, int, int, ScheduledExecutorService, Logger).
      Parameters:
      componentName - The name of the component to be included in the logging
      timeout - The timeout in milliseconds
      warningThreshold - The threshold in milliseconds after which a warning is logged. Setting this to a value higher than timeout will 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 new UnitOfWorkTimeoutInterceptor for the given componentName with the given timeout, warningThreshold and warningInterval. The warnings and timeout will be scheduled on the provided executorService.
      Parameters:
      componentName - The name of the component to be included in the logging
      timeout - The timeout in milliseconds
      warningThreshold - The threshold in milliseconds after which a warning is logged. Setting this to a value higher than timeout will disable warnings.
      warningInterval - The interval in milliseconds between warnings.
      executorService - The executor service to schedule the timeout and warnings
      logger - The logger to log warnings and errors
  • Method Details