-
- 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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default RegistrationawaitAck(long timeout, TimeUnit unit)Wait for the acknowledgement of the original instructionthisRegistrationcorresponds to.CompletableFuture<Void>cancel()Cancel the registration from which this instance was returned.default RegistrationonAck(Runnable runnable)Registers the givenrunnabletothisRegistrationto be executed when the acknowledgement ofthisRegistrationis received.default RegistrationonAck(Consumer<Optional<Throwable>> action)Registers the givenrunnabletothisRegistrationto be executed when the acknowledgement ofthisRegistrationis received.
-
-
-
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
CompletableFutureofVoidto react whenthisRegistrationhas been canceled
-
awaitAck
default Registration awaitAck(long timeout, TimeUnit unit) throws TimeoutException, InterruptedException
Wait for the acknowledgement of the original instructionthisRegistrationcorresponds to. Allows for the addition of further logic tothis Registration, like invokingonAck(Runnable)for example.- Parameters:
timeout- the duration to wait until the operation has been acknowledgedunit- theTimeUnitfor the giventimeoutto wait until the operation has been acknowledged- Returns:
- this Registration to support a fluent API
- Throws:
TimeoutException- is thrown when the giventimeoutandunitis surpassedInterruptedException- is thrown when the thread waiting for the acknowledgement is interrupted
-
onAck
default Registration onAck(Runnable runnable)
Registers the givenrunnabletothisRegistrationto be executed when the acknowledgement ofthisRegistrationis received. Allows for the addition of further logic tothis Registration, like invokingawaitAck(long, TimeUnit)for example.The given
runnableis invoked, regardless of successful or failed acknowledgement. UseonAck(Consumer)to register an action that needs to distinguish between successful and failed registration.- Parameters:
runnable- theRunnableto execute when the acknowledgement ofthisRegistrationis received- Returns:
- this Registration to support a fluent API
-
onAck
default Registration onAck(Consumer<Optional<Throwable>> action)
Registers the givenrunnabletothisRegistrationto be executed when the acknowledgement ofthisRegistrationis received. Allows for the addition of further logic tothis Registration, like invokingawaitAck(long, TimeUnit)for example.- Parameters:
action- the action to execute when the acknowledgement ofthisRegistrationis received, either normally or exceptionally.- Returns:
- this Registration to support a fluent API
-
-