Interface SourceResultHandler<T,A>
- Type Parameters:
T- the generic type of the result output valueA- the generic type of the result attributes value
ExtensionsClient to notify of new results produced by a source created through the
ExtensionsClient.createSource(String, String, Consumer, Consumer) method.
Clients will obtain the produced value by calling the getResult() method.
After processing the result, clients MUST invoke either completeWithSuccess(Consumer) or
completeWithError(Throwable, Consumer), so that the source can finish the processing of each individual result. Refer
to those method's javadocs for further details on their semantics.
NOTE: Experimental feature. Backwards compatibility not guaranteed.
- Since:
- 1.5.0
-
Method Summary
Modifier and TypeMethodDescriptioncompleteWithError(Throwable exception, Consumer<SourceCallbackParameterizer> errorCallbackParameters) Executes the source's error callback.completeWithSuccess(Consumer<SourceCallbackParameterizer> successCallbackParameters) Executes the source's completion callback.
-
Method Details
-
getResult
- Returns:
- a
Resultproduced by the message source
-
completeWithSuccess
CompletableFuture<Void> completeWithSuccess(Consumer<SourceCallbackParameterizer> successCallbackParameters) Executes the source's completion callback. This method MUST be invoked when the client has successfully processed thegetResult(), even if theSourceModeldoesn't explicitly define a successSourceCallbackModel.The actual effect of calling this method will depend on the source (some will emit a response back to the client, some will update internal state, etc.). The action is however asynchronous, for which the method returns a
CompletableFuture, which will either complete with a void value or an Exception.Unlike what happens with a source created inside a Mule app, should this method fail (either synchronously upon invocation or asynchronously with an exceptional completion of the return future), the
completeWithError(Throwable, Consumer)method will not be called automatically.Finally, this method should only be called at most once per instance and should be mutually exclusive with
completeWithError(Throwable, Consumer), which means that if one is called, the other one shouldn't.- Parameters:
successCallbackParameters- parameterizes the source's success callback.- Returns:
- a
CompletableFuture
-
completeWithError
CompletableFuture<Void> completeWithError(Throwable exception, Consumer<SourceCallbackParameterizer> errorCallbackParameters) Executes the source's error callback. This method MUST be invoked when the client has encountered an Exception while processing thegetResult()which should be notified back to the source so that it considers the Result as a failed event. This must be done even if theSourceModeldoesn't explicitly define an errorSourceCallbackModel.The actual effect of calling this method will depend on the source (some will emit a response back to the client, some will update internal state, etc.). The action is however asynchronous, for which the method returns a
CompletableFuture, which will either complete with a void value or an Exception.Finally, this method should only be called at most once per instance and should be mutually exclusive with
completeWithSuccess(Consumer), which means that if one is called, the other one shouldn't.- Parameters:
exception- The exception founderrorCallbackParameters- parameterizes the source's error callback.- Returns:
- a
CompletableFuture
-