Setup DynamoDB Trigger using Lambda(使用 Lambda 设置 DynamoDB 触发器)
问题描述
我正在尝试使用 DynamoDB Streams 和 AWS Lambda 创建一个 DynamoDB 触发器.我进行了很多研究,但找不到任何方法来读取和处理 Java 8 中的 DynamoDB Stream 事件.我对这两种技术都是全新的,所以不知道如何使用它.
I'm trying to create a DynamoDB trigger using DynamoDB Streams and AWS Lambda. I researched a lot but I couldn't find any way to read and process a DynamoDB Stream event in Java 8. I'm completely new to both these technologies so don't know how to work with this.
本质上,我想做的是每当在表 A 中创建记录时在表 B 中创建记录.
Essentially, what I want to do is create a record in table B whenever a record is created in table A.
谁能给我指出一个用Java处理这个用例的代码或帖子?
Could any of you please point me to a code or post that handles this use case in Java?
谢谢:)
推荐答案
这段代码对我有用.您可以使用它在 Lambda 函数中接收和处理 DynamoDB 事件 -
This code worked for me. You can use it to receive and process DynamoDB events in a Lambda function -
public class Handler implements RequestHandler<DynamodbEvent, Void> {
@Override
public Void handleRequest(DynamodbEvent dynamodbEvent, Context context) {
for (DynamodbStreamRecord record : dynamodbEvent.getRecords()) {
if (record == null) {
continue;
}
// Your code here
// Write to Table B using DynamoDB Java API
}
return null;
}
}
创建 Lambda 时,将表 A 中的流添加为事件源,一切顺利
When you create your Lambda, add the stream from table A as your event source, and you're good to go
这篇关于使用 Lambda 设置 DynamoDB 触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Lambda 设置 DynamoDB 触发器
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Struts2 URL 无法访问 2022-01-01
