Type Parameters:
T - the generic type of the output values of the generated results
A - the generic type of the attributes of the generated results

@MinMuleVersion("4.1") @NoImplement public interface SourceCallback<T,A>
A callback to allow 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 Type
    Method
    Description
     
    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.
  • Method Details

    • handle

      void handle(Result<T,A> result)
      Passes the given result back to the runtime for processing.
      Parameters:
      result - a Result
    • handle

      void handle(Result<T,A> result, SourceCallbackContext context)
      Passes the given 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

      Parameters:
      result - a Result
      context - context a SourceCallbackContext
    • onConnectionException

      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.

      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.

      Parameters:
      e - the ConnectionException we need to recover from.
    • createContext

      SourceCallbackContext createContext()
      Returns:
      a new instance of SourceCallbackContext, only valid for use on this same SourceCallback instance