我正在尝试使用Java lambda函数转换firehose中的数据。我在服务器中的用户代理会将数据发送到firehose,而lambda将转换数据。现在的问题是我使用下面的代码来检索记录
public String handleRequest(KinesisEvent event, Context context) {
context.getLogger().log("Input: " + event);
for (KinesisEventRecord record : event.getRecords()) {
String payload = new String(record.getKinesis().getData().array());
context.getLogger().log("Payload: " + payload);
}
return "";
}
但是我在for循环行中得到了一个Null指针。我在这里想念什么? KinesisEvent不能用于获取firehose数据吗?谁能帮助我
如果我们使用的是node.js,则下面的代码将获得记录
use strict';
console.log('Loading function');
exports.handler = (event, context, callback) => {
/* Process the list of records and transform them */
const output = event.records.map((record) => ({
/* This transformation is the "identity" transformation, the data is left intact */
recordId: record.recordId,
result: 'Ok',
data: record.data,
}));
console.log(`Processing completed. Successful records ${output.length}.`);
callback(null, { records: output });
};