Package org.talend.transform.runtime.api

# Interface MessageAdaptor

public interface MessageAdaptor
Provides an interface from the transformer runtime to an external messaging system.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`TYPE_BINARY`
A binary source or result, uses an InputStream or OutputStream with the StreamSource or StreamResult.
`static final int`
`TYPE_CHARACTER`
A character source or result.

## Method Summary

Modifier and Type
Method
Description
`Source`
`readMessage(MapExecutionContext ec, Class sourceClass, int sourceType, Object endpoint, Map<String,Object> properties)`
Reads a message with the given endpoint from the messaging system.
`void`
`writeMessageFinish(MapExecutionContext ec, Result result, Object endpoint, Map<String,Object> properties)`
Called when writing to the Result is finished for a message.
`void`
`writeMessageProperties(MapExecutionContext ec, Map<String,Object> properties)`
Used to set the properties of the message being written.
`Result`
`writeMessageStart(MapExecutionContext ec, Class resultClass, int resultType, Object endpoint, boolean waitForProperties, Map<String,Object> properties)`
Called before the writing is to begin on a message.

## Field Details

### TYPE_CHARACTER

static final int TYPE_CHARACTER
A character source or result. Uses a Reader or Writer with the StreamSource or StreamResult.

See Also:
  - Constant Field Values

### TYPE_BINARY

static final int TYPE_BINARY
A binary source or result, uses an InputStream or OutputStream with the StreamSource or StreamResult.

See Also:
  - Constant Field Values

## Method Details

### readMessage

Source readMessage(MapExecutionContext ec, Class sourceClass, int sourceType, Object endpoint, Map<String,Object> properties)
Reads a message with the given endpoint from the messaging system.

Parameters:
  `sourceClass` - the desired class of the Source object
  `sourceType` - indicates the desired type qualifying the source (binary or character)
  `endpoint` - endpoint from which to read the message
  `properties` - if specified, asks that the object be populated with the message's properties
Returns:
  a Source object that refers to the message data.

### writeMessageStart

Result writeMessageStart(MapExecutionContext ec, Class resultClass, int resultType, Object endpoint, boolean waitForProperties, Map<String,Object> properties)
Called before the writing is to begin on a message. For streaming messages this can allocate and send the message with the correct stream so the downstream processing can be parallel. For non-streaming messages, this should only return the desired type of Result object and the message is written later at writeMessageFinish(). In either case, the desired Result object must be returned.

Parameters:
  `resultClass` - the desired class of the Result object
  `resultType` - indicates the desired type qualifying the result (binary or character)
  `endpoint` - endpoint to write the message to (optional, only if named endpoints are used)
  `properties` - the properties to use for the message.
  `waitForProperties` - if true, wait for a subsequent call to writeMessageProperties() which contains the values for the properties
Returns:
  a Result object that will be used to write the message data.

### writeMessageProperties

void writeMessageProperties(MapExecutionContext ec, Map<String,Object> properties)
Used to set the properties of the message being written. This is called only if the waitForProperties bit is set in the writeMessageStart() method.

Parameters:
  `ec` -
  `properties` -

### writeMessageFinish

void writeMessageFinish(MapExecutionContext ec, Result result, Object endpoint, Map<String,Object> properties)
Called when writing to the Result is finished for a message. For non-streaming messages, this should allocate and send the message. For streaming messages, this should do nothing.

Parameters:
  `result` - a Result object that refers to the data to be included in the message.
  `endpoint` - endpoint to write the message to (optional, only if named endpoints are used)
  `properties` - the properties to use for the message.