Interface Registration

All Known Implementing Classes:
AbstractWebsocketClient.PingRegistration, DefaultTracker
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Registration
Represents a handle for a cancellable registration, such as a subscription, listener, or callback.

The Registration interface is widely used throughout Flux Capacitor to manage lifecycle-bound resources like message consumers, handler tracking, interceptors, and more. Calling cancel() releases the associated resource.

Usage


 Registration registration = tracker.start();

 // Later
 registration.cancel(); // Stops tracking
 

Combining multiple registrations

The merge(Registration) method allows combining multiple registrations into a single handle. Cancelling the combined registration will cancel both underlying registrations:

 Registration r1 = trackerA.start();
 Registration r2 = trackerB.start();
 Registration combined = r1.merge(r2);

 combined.cancel(); // Cancels both r1 and r2
 

No-op Registration

Use noOp() to obtain a dummy Registration that performs no action when cancelled.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Cancels the resource or subscription associated with this registration.
    default Registration
    merge(Registration otherRegistration)
    Returns a new Registration that cancels both this and the given otherRegistration.
    Returns a no-op Registration that does nothing on cancel().
  • Method Details

    • noOp

      static Registration noOp()
      Returns a no-op Registration that does nothing on cancel().
    • cancel

      void cancel()
      Cancels the resource or subscription associated with this registration.

      Calling this method should be idempotent and safe to invoke multiple times.

    • merge

      default Registration merge(Registration otherRegistration)
      Returns a new Registration that cancels both this and the given otherRegistration.

      This is useful when managing multiple resources together:

      
       Registration combined = reg1.merge(reg2);
       
      Parameters:
      otherRegistration - another registration to combine with this one
      Returns:
      a composite registration