T - the generic type of the output values of the generated resultsA - the generic type of the attributes of the generated resultspublic interface SourceCallback<T,A>
Source implementations to communicate
generated messages back to the runtime so that they can be processed.
Those messages will be represented as Result objects
using the handle(Result) or handle(Result, SourceCallbackContext)
methods.
| Modifier and Type | Method and Description |
|---|---|
SourceCallbackContext |
createContext() |
void |
handle(Result<T,A> result)
Passes the given
result back to the runtime for processing. |
void |
handle(Result<T,A> result,
SourceCallbackContext context)
Passes the given
result back to the runtime for processing. |
void |
onSourceException(Throwable t)
Any started
Source must use this method to communicate the runtime that
an exception was found trying to produce messages. |
void handle(Result<T,A> result)
result back to the runtime for processing.result - a Resultvoid handle(Result<T,A> result, SourceCallbackContext context)
result back to the runtime for processing.
This method also allows providing a SourceCallbackContext
so that state can be associated to each result.
This is specially helpful for sources which emits responses on stateful connections or which require to pass back some kind of token or identifier. Notice that this is not the only possible use case though.
The context instance should be created using the
createContext() of this same instance
result - a Resultcontext - context a SourceCallbackContextvoid onSourceException(Throwable t)
Source must use this method to communicate the runtime that
an exception was found trying to produce messages. Any exceptions that the source
encounters trying to produce messages needs to be channeled through this method
and NOT be thrown.
Do not confuse the concept of 'exception found producing a message' from a
message which failed to be processed by the flow or an exception thrown by
a method annotated with OnSuccess or OnError. Any of those
represent an expected processing failure and need to be treated accordingly
by the source itself. Those are not something that the runtime should be
notified about.
t - a ThrowableSourceCallbackContext createContext()
SourceCallbackContext, only
valid for use on this same SourceCallback instanceCopyright © 2017 MuleSoft, Inc.. All rights reserved.