如何使用 apache camel 扫描 dynamodb table?
How to scan a dynamodb table using apache camel?
我有一个 camel rest api 可以扫描 DynamoDb table。代码是这样的 ->
.post("dynamodb-scan-table")
.route()
.toD("aws2-ddb://user?accessKey=insert&secretKey=insert®ion=us-east-1&operation=Scan")
.endRest();
这个returns我的table中的所有项目。我的问题是如何根据特定条件扫描 table。在骆驼 docs 中,给出了 header CamelAwsDdbScanFilter
类型需要设置 Map<String, Condition>
才能解决我的问题。我有 table 个用户,假设我想检索 FirsName = Will
个用户。如何实现 Map<String, Condition>
以实现此目的?基本上我不确定在地图的 Condition
中放什么。
您可以在 ScanCommandTest 中找到示例用法。
对于条件 FirstName
eq Will
过滤器可能是这样的:
exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, new HashMap<String, Condition>(){{
put("FirsName", new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS("Will")));
}});
我有一个 camel rest api 可以扫描 DynamoDb table。代码是这样的 ->
.post("dynamodb-scan-table")
.route()
.toD("aws2-ddb://user?accessKey=insert&secretKey=insert®ion=us-east-1&operation=Scan")
.endRest();
这个returns我的table中的所有项目。我的问题是如何根据特定条件扫描 table。在骆驼 docs 中,给出了 header CamelAwsDdbScanFilter
类型需要设置 Map<String, Condition>
才能解决我的问题。我有 table 个用户,假设我想检索 FirsName = Will
个用户。如何实现 Map<String, Condition>
以实现此目的?基本上我不确定在地图的 Condition
中放什么。
您可以在 ScanCommandTest 中找到示例用法。
对于条件 FirstName
eq Will
过滤器可能是这样的:
exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, new HashMap<String, Condition>(){{
put("FirsName", new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS("Will")));
}});