Interface SourceCallback<T,A>
- Type Parameters:
T- the generic type of the output values of the generated resultsA- the generic type of the attributes of the generated results
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.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidPasses the givenresultback to the runtime for processing.voidhandle(Result<T, A> result, SourceCallbackContext context) Passes the givenresultback to the runtime for processing.voidonConnectionException(org.mule.runtime.api.connection.ConnectionException e) Any startedSourcemust use this method to communicate the runtime that aConnectionExceptionwas found trying to produce messages.
-
Method Details
-
handle
Passes the givenresultback to the runtime for processing.- Parameters:
result- aResult
-
handle
Passes the givenresultback to the runtime for processing. This method also allows providing aSourceCallbackContextso that state can be associated to eachresult.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
contextinstance should be created using thecreateContext()ofthissame instance- Parameters:
result- aResultcontext- context aSourceCallbackContext
-
onConnectionException
void onConnectionException(org.mule.runtime.api.connection.ConnectionException e) Any startedSourcemust use this method to communicate the runtime that aConnectionExceptionwas 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 relatedSourceimplements theReconnectableinterface, thenReconnectable.reconnect(ConnectionException, ReconnectionCallback)will be invoked, otherwise the runtime will try to reestablish connection by restarting the owningSource. In case that theConnectionExceptioncommunicates which is the connection with connectivity issues, the runtime will invalidate it, disconnecting and destroying it.- Parameters:
e- theConnectionExceptionwe need to recover from.
-
createContext
SourceCallbackContext createContext()- Returns:
- a new instance of
SourceCallbackContext, only valid for use onthissameSourceCallbackinstance
-