Interface SourceCallbackContext


@MinMuleVersion("4.1") @NoImplement public interface SourceCallbackContext
A context interface to correlate a message generated by a Source to a particular state
Since:
1.0
  • Method Details

    • bindConnection

      TransactionHandle bindConnection(Object connection) throws org.mule.runtime.api.connection.ConnectionException, org.mule.runtime.api.tx.TransactionException
      Associates the given connection to this context. As a result of this binding, the runtime will automatically take care of releasing the connection once the source has finished processing the response and will also take care of resolving the associated transaction (if any).

      If the connection is a TransactionalConnection and the source was configured to be transactional, then this method will start such transaction.

      Parameters:
      connection - the connection to be bound
      Returns:
      a TransactionHandle produced as a result of the binding
      Throws:
      org.mule.runtime.api.connection.ConnectionException - if the connection is not valid or cannot be used
      org.mule.runtime.api.tx.TransactionException - if a transaction was needed but couldn't be started.
    • getConnection

      <T> T getConnection() throws IllegalStateException
      Returns the connection that was bound through bindConnection(Object).

      If that method was not called, then it will throw IllegalStateException

      Type Parameters:
      T - the generic type of the connection
      Returns:
      the bound connection
      Throws:
      IllegalStateException - if no connection bound
    • getTransactionHandle

      TransactionHandle getTransactionHandle()
      A handle to the current on-going transaction. If no transaction is active, then you get a handle which represents a void transaction, but this method will never return null.

      This method can be used without the need for bindConnection(Object) to had been invoked on this instance first. However if it has, then the result of this method will be the exact same instance that bindConnection(Object) returned.

      Returns:
      the current TransactionHandle
    • hasVariable

      boolean hasVariable(String variableName)
      Returns whether a variable of name variableName has a value associated to it through the addVariable(String, Object) method
      Parameters:
      variableName - the name of a variable associated to a particular SourceCallback
      Returns:
      true if the parameter is present.
    • getVariable

      <T> Optional<T> getVariable(String variableName)
      Returns the value associated to a variable of name variableName
      Type Parameters:
      T - the returned value's generic type
      Parameters:
      variableName - the name of a variable of a SourceCallback
      Returns:
      an Optional of the variable's value.
    • addVariable

      void addVariable(String variableName, Object value)
      Adds a variable
      Parameters:
      variableName - the name of the variable
      value - the variable's value
    • setCorrelationId

      void setCorrelationId(String correlationId)
      Sets the correlationId of the event that will be passed to the flow when the SourceCallback.handle(Result, SourceCallbackContext) method is invoked.

      This method can only be invoked BEFORE this instance has been used on a SourceCallback.handle(Result, SourceCallbackContext) operation. Otherwise, an IllegalStateException will be thrown.

      Parameters:
      correlationId - a correlationId
      Throws:
      IllegalArgumentException - if invoked once this context has already been used to push a message
      Since:
      1.1
    • getCorrelationId

      Optional<String> getCorrelationId()
      Returns:
      Optionally returns the correlationId set through setCorrelationId(String) (if any).
      Since:
      1.1
    • getSourceCallback

      <T, A> SourceCallback<T,A> getSourceCallback()
      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
      Returns:
      The SourceCallback that generated this context
    • fireOnHandle

      void fireOnHandle(NotificationActionDefinition<?> action, org.mule.runtime.api.metadata.TypedValue<?> data)
      Indicates that an ExtensionNotification should be fired with the desired information when the runtime takes the source result to process it.
      Parameters:
      action - the NotificationActionDefinition to use.
      data - the TypedValue data to use.
      Since:
      4.1