Interface Registration

  • All Known Implementing Classes:
    AsyncRegistration, SyncRegistration
    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
    Interface describing an instruction to perform a registration, which can be canceled.
    • Method Detail

      • cancel

        CompletableFuture<Void> cancel()
        Cancel the registration from which this instance was returned. Does nothing if the registration has already been canceled, or when the registration was undone by another mechanism (such as a new registration overriding this one).
        Returns:
        a CompletableFuture of Void to react when this Registration has been canceled
      • awaitAck

        default Registration awaitAck​(long timeout,
                                      TimeUnit unit)
                               throws TimeoutException,
                                      InterruptedException
        Wait for the acknowledgement of the original instruction this Registration corresponds to. Allows for the addition of further logic to this Registration, like invoking onAck(Runnable) for example.
        Parameters:
        timeout - the duration to wait until the operation has been acknowledged
        unit - the TimeUnit for the given timeout to wait until the operation has been acknowledged
        Returns:
        this Registration to support a fluent API
        Throws:
        TimeoutException - is thrown when the given timeout and unit is surpassed
        InterruptedException - is thrown when the thread waiting for the acknowledgement is interrupted
      • onAck

        default Registration onAck​(Runnable runnable)
        Registers the given runnable to this Registration to be executed when the acknowledgement of this Registration is received. Allows for the addition of further logic to this Registration, like invoking awaitAck(long, TimeUnit) for example.

        The given runnable is invoked, regardless of successful or failed acknowledgement. Use onAck(Consumer) to register an action that needs to distinguish between successful and failed registration.

        Parameters:
        runnable - the Runnable to execute when the acknowledgement of this Registration is received
        Returns:
        this Registration to support a fluent API
      • onAck

        default Registration onAck​(Consumer<Optional<Throwable>> action)
        Registers the given runnable to this Registration to be executed when the acknowledgement of this Registration is received. Allows for the addition of further logic to this Registration, like invoking awaitAck(long, TimeUnit) for example.
        Parameters:
        action - the action to execute when the acknowledgement of this Registration is received, either normally or exceptionally.
        Returns:
        this Registration to support a fluent API