Kinesis Firehose 流接收消息。有一個選項可以持久保存到 S3 中,但我的用例是插入到 dynamodb 表中。Firehose 有一個啟用 Lambda 函數的選項。我應該使用 Lambda 將插入邏輯寫入 dynamodb 表嗎?這是正確的方法嗎?如果是這樣,那么如何使用用 Java 編寫的 Lambda 將記錄插入到 DynamoDB 中。
1 回答

ibeautiful
TA貢獻1993條經驗 獲得超6個贊
沒有將 Firehose 流數據插入 DynamoDB(例如 S3 或 Redshift)的標準方法。推薦的方法是執行 Lambda 并將記錄插入到 DynamoDB 中。
使用dynamoDB.batchWriteItem
或dynamoDB.putItem
。
public String handleRequest(KinesisFirehoseEvent event, Context context)
? ? List<KinesisFirehoseEvent.Record> records = event.getRecords();
? ? for(KinesisFirehoseEvent.Record rec : records)
? ? {
? ? ? ? String recordId = rec.getRecordId();
? ? ? ? String data = StandardCharsets.UTF_8.decode(rec.getData()).toString();
? ? ? ? Item item = transformStringToItem(data);
? ? ? ? // Write the item to the table?
? ? ? ? table.putItem(item);
? ? }
? ? return "success";
}
添加回答
舉報
0/150
提交
取消