When the adapter framework calls this method, it is expected to run continuously
until the adapter is requested to stop or until the adapter completes its work.
Therefore, the code excerpt below might be found within a loop, or inside a
callback method invoked by the transport when an event occurs, or inside a
listener monitoring transport events.
AepRecord is a single record or row in ESP format
and has an operation code that can be set. AdapterRow represents records as they
flow from one module to the next. You can add multiple records as objects within a
List of a single AdapterRow object. The AdapterRow has a timestamp, and block
flags that control how its records are communicated to and from
Event Stream Processor. See Envelopes and
Transactions for additional details.
The actions performed by this function depend on whether the transporter is input
(datasource) or output (data sink). For example, for an input transporter which
gets data from “myDataSource”, the
execute() function might
look like
this:
public void execute() throws Exception {
String value = myDataSource.getNextValue();
AepRecord record = new AepRecord();
record.getValues().add(value);
AdapterRow row = utility.createRow(record);
utility.sendRow(row);
}
For an output transporter which sends data to “myDataSink”, the
execute() function might look like
this:
public void execute() throws Exception {
AdapterRow row = utility.getRow();
if(row != null)
{
AepRecord record = (AepRecord)row.getData(0);
if(record != null) {
String value = record.getValues().toString();
myDataSink.send(value);
}
}
The difference between input and output transporters is that input transporters
call utility.sendRow() to send data to a formatter or
ESP publisher, while output transporters call
utility.getRow() to obtain data from a formatter or
ESP subscriber.
For transporters that operate in streaming mode, call
utility.sendRowsBuffer() (input) and
utility.getRowsBuffer() (output).
See the $ESP_HOME/adapters/framework/examples/src directory
for source code for sample transporters.