T - the generic type of the output values of the generated resultsA - the generic type of the attributes of the generated results@NoImplement
public 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 |
onConnectionException(org.mule.runtime.api.connection.ConnectionException e)
Any started
Source must use this method to communicate the runtime that
a ConnectionExceptionwas 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 onConnectionException(org.mule.runtime.api.connection.ConnectionException e)
Source must use this method to communicate the runtime that
a ConnectionExceptionwas found trying to produce messages.
This callback is to be used for connectivity errors that happen after
Source.onStart(SourceCallback) has successfully returned (otherwise,
you can simply throw the exception there).
When notified of the exception through this method, the runtime will decide if reconnection is to be
attempted, depending on the configuration. If the related Source implements the Reconnectable
interface, then Reconnectable.reconnect(ConnectionException, ReconnectionCallback) will be invoked,
otherwise the runtime will try to reestablish connection by restarting the owning Source.
In case that the ConnectionException communicates which is the connection with connectivity issues,
the runtime will invalidate it, disconnecting and destroying it.
e - the ConnectionException we need to recover from.SourceCallbackContext createContext()
SourceCallbackContext, only
valid for use on this same SourceCallback instanceCopyright © 2019 MuleSoft, Inc.. All rights reserved.