use of software.amazon.kinesis.retrieval.KinesisClientRecord in project pulsar by apache.
the class KinesisRecordProcessor method processRecords.
@Override
public void processRecords(ProcessRecordsInput processRecordsInput) {
log.info("Processing " + processRecordsInput.records().size() + " records from " + kinesisShardId);
for (KinesisClientRecord record : processRecordsInput.records()) {
try {
queue.put(new KinesisRecord(record));
} catch (InterruptedException e) {
log.warn("unable to create KinesisRecord ", e);
}
}
// Checkpoint once every checkpoint interval.
if (System.nanoTime() > nextCheckpointTimeInNanos) {
checkpoint(processRecordsInput.checkpointer());
nextCheckpointTimeInNanos = System.nanoTime() + checkpointInterval;
}
}
use of software.amazon.kinesis.retrieval.KinesisClientRecord in project aws-glue-schema-registry by awslabs.
the class GlueSchemaRegistryRecordProcessor method processRecords.
public void processRecords(ProcessRecordsInput processRecordsInput) {
this.recordProcessor.consumptionSuccess = true;
try {
LOGGER.info("Processing {} record(s)", processRecordsInput.records().size());
for (KinesisClientRecord r : processRecordsInput.records()) {
ByteBuffer bb = r.data();
byte[] bytes = new byte[bb.remaining()];
bb.get(bytes);
Schema gsrSchema = glueSchemaRegistryDeserializer.getSchema(bytes);
LOGGER.info("Consumed Schema from GSR : {}", gsrSchema.getSchemaDefinition());
Object decodedRecord = glueSchemaRegistryDeserializerFactory.getInstance(DataFormat.valueOf(gsrSchema.getDataFormat()), gsrConfig).deserialize(ByteBuffer.wrap(bytes), gsrSchema);
this.recordProcessor.consumedRecords.add(decodedRecord);
LOGGER.info("Processed record: {}", decodedRecord);
}
} catch (Exception e) {
LOGGER.error("Failed while processing records. Aborting", e);
Runtime.getRuntime().halt(1);
}
}
Aggregations