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 触发器


- C++ 和 Java 进程之间的共享内存 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01