Java Code Examples for com.amazonaws.services.lambda.runtime.events.KinesisEvent#getRecords()

The following examples show how to use com.amazonaws.services.lambda.runtime.events.KinesisEvent#getRecords() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KinesisHandler.java    From bender with Apache License 2.0 6 votes vote down vote up
public void handler(KinesisEvent event, Context context) throws HandlerException {
  if (!initialized) {
    init(context);
  }

  KinesisHandlerConfig handlerConfig = (KinesisHandlerConfig) this.config.getHandlerConfig();
  this.recordIterator = new KinesisEventIterator(new LambdaContext(context),
          event.getRecords(),
          handlerConfig.getAddShardIdToPartitions(),
          handlerConfig.getDecompress(),
          handlerConfig.getBufferSize());

  /*
   * Get processors based on the source stream ARN
   */
  KinesisEventRecord firstRecord = event.getRecords().get(0);
  this.source = SourceUtils.getSource(firstRecord.getEventSourceARN(), sources);

  super.process(context);
}
 
Example 2
Source File: EchoHandler.java    From kinesis-aggregation with Apache License 2.0 6 votes vote down vote up
@Override
public Void handleRequest(KinesisEvent event, Context context) {
	LambdaLogger logger = context.getLogger();

	// extract the records from the event
	List<KinesisEventRecord> records = event.getRecords();

	logger.log(String.format("Recieved %s Raw Records", records.size()));

	// now deaggregate the message contents
	List<UserRecord> deaggregated = new RecordDeaggregator<KinesisEventRecord>().deaggregate(records);
	logger.log(String.format("Received %s Deaggregated User Records", deaggregated.size()));
	
	deaggregated.stream().forEachOrdered(rec -> {
		logger.log(rec.getPartitionKey());
	});

	return null;
}
 
Example 3
Source File: EchoHandler.java    From kinesis-aggregation with Apache License 2.0 6 votes vote down vote up
@Override
public Void handleRequest(KinesisEvent event, Context context) {
	LambdaLogger logger = context.getLogger();

	// extract the records from the event
	List<KinesisEventRecord> records = event.getRecords();

	logger.log(String.format("Recieved %s Raw Records", records.size()));

	try {
		// now deaggregate the message contents
		List<KinesisClientRecord> deaggregated = new RecordDeaggregator<KinesisEventRecord>().deaggregate(records);
		logger.log(String.format("Received %s Deaggregated User Records", deaggregated.size()));

		deaggregated.stream().forEachOrdered(rec -> {
			logger.log(rec.partitionKey());
		});
	} catch (Exception e) {
		logger.log(e.getMessage());
	}

	return null;
}
 
Example 4
Source File: KinesisToFirehose.java    From aws-big-data-blog with Apache License 2.0 6 votes vote down vote up
public void kinesisHandler(KinesisEvent event, Context context){
    logger = context.getLogger();
    setup();
    for(KinesisEvent.KinesisEventRecord rec : event.getRecords()) {
        logger.log("Got message ");
        String msg = new String(rec.getKinesis().getData().array())+"\n";
        Record deliveryStreamRecord = new Record().withData(ByteBuffer.wrap(msg.getBytes()));

        PutRecordRequest putRecordRequest = new PutRecordRequest()
                .withDeliveryStreamName(deliveryStreamName)
                .withRecord(deliveryStreamRecord);

        logger.log("Putting message");
        firehoseClient.putRecord(putRecordRequest);
        logger.log("Successful Put");
    }
}
 
Example 5
Source File: SpringBootKinesisEventHandler.java    From service-block-samples with Apache License 2.0 4 votes vote down vote up
@Override
protected List<KinesisEventRecord> convertEvent(KinesisEvent event) {
	// TODO: maybe convert to List<Message>
	return event.getRecords();
}