Class FluxCapacitorInterceptor

java.lang.Object
io.fluxcapacitor.javaclient.tracking.FluxCapacitorInterceptor
All Implemented Interfaces:
BatchInterceptor

public class FluxCapacitorInterceptor extends Object implements BatchInterceptor
A BatchInterceptor that ensures the correct FluxCapacitor instance is bound to the current thread for the duration of a MessageBatch.

This interceptor enables the use of FluxCapacitor's static convenience methods during message processing. It ensures that operations like FluxCapacitor.sendCommand(Object) or FluxCapacitor.publishEvent(Object) resolve the correct runtime context even in multithreaded applications.

Thread-Local Binding

  • Sets FluxCapacitor.instance before batch processing begins.
  • Restores the previous thread-local instance (if any) after processing completes.
  • Ensures thread isolation across different trackers and test threads.

Runtime Expectations

  • In a typical production application, there is a single FluxCapacitor instance used throughout the JVM.
  • This instance is often registered via FluxCapacitor.applicationInstance and used as a fallback when no thread-local binding is available.
  • Multiple instances may occur in rare cases—such as connecting to multiple Flux platforms—or during unit/integration testing scenarios involving multiple test clients or parallel test execution.
  • This interceptor ensures that each batch is processed with the appropriate context, even in such edge cases.

Lifecycle

  • This interceptor is registered automatically in most Flux Capacitor configurations.
  • In custom or manual configurations (e.g., test setups), it may need to be included explicitly.
See Also:
  • Constructor Details

    • FluxCapacitorInterceptor

      public FluxCapacitorInterceptor()
  • Method Details