@NoImplement public interface SourceCompletionCallback
sources
in order tell the runtime that they will process the flow's response
in an asynchronous manner (from now on, async sources).
Main uses cases for async sources are (but not limited to):
OnSuccess
orOnError
In those use cases, the runtime needs to know that the response will be asynchronous because otherwise it will generate a race condition between the thread emitting the response and the runtime itself which is trying to free up resources associated with the message being responded to.
In those use cases, the methods annotated with OnSuccess
or OnError
can have an argument
of this type. That's enough to signal the runtime that the source is an async one. The runtime will not finish
the associated event until either success()
or error(Throwable)
methods are invoked. Notice
this is a very strong piece of the contract. A source which requests a SourceCompletionCallback
but then
doesn't properly notifies it is one likely to eventually freeze the entire runtime!.
Let's see a quick example:
Modifier and Type | Method and Description |
---|---|
void |
error(Throwable t)
Signals the runtime that the response was processed, but with an error
|
void |
success()
Signals the runtime that it has successfully processed the response
|
void success()
void error(Throwable t)
t
- the catched errorCopyright © 2018. All rights reserved.