Search in sources :

Example 6 with PutRecordRequest

use of com.amazonaws.services.kinesis.model.PutRecordRequest in project apex-malhar by apache.

the class AbstractKinesisOutputOperator method processTuple.

public void processTuple(T tuple) {
    // Send out single data
    try {
        if (isBatchProcessing) {
            if (putRecordsRequestEntryList.size() == batchSize) {
                flushRecords();
                logger.debug("flushed {} records.", batchSize);
            }
            addRecord(tuple);
        } else {
            Pair<String, V> keyValue = tupleToKeyValue(tuple);
            PutRecordRequest requestRecord = new PutRecordRequest();
            requestRecord.setStreamName(streamName);
            requestRecord.setPartitionKey(keyValue.first);
            requestRecord.setData(ByteBuffer.wrap(getRecord(keyValue.second)));
            client.putRecord(requestRecord);
        }
        sendCount++;
    } catch (AmazonClientException e) {
        throw new RuntimeException(e);
    }
}
Also used : PutRecordRequest(com.amazonaws.services.kinesis.model.PutRecordRequest) AmazonClientException(com.amazonaws.AmazonClientException)

Aggregations

PutRecordRequest (com.amazonaws.services.kinesis.model.PutRecordRequest)6 ByteBuffer (java.nio.ByteBuffer)2 Test (org.junit.Test)2 AmazonClientException (com.amazonaws.AmazonClientException)1 PutRecordResult (com.amazonaws.services.kinesis.model.PutRecordResult)1 Message (org.apache.camel.Message)1