如何使用apachecamel扫描dynamodb表



我有一个camel-rest api,它扫描DynamoDb表。代码是这样的->

.post("dynamodb-scan-table")
.route()
.toD("aws2-ddb://user?accessKey=insert&secretKey=insert&region=us-east-1&operation=Scan")
.endRest();

这将返回我表中的所有项目。我的问题是如何根据特定条件扫描表格。在骆驼文档中,有一个标题CamelAwsDdbScanFilter,它的类型为Map<String, Condition>,需要设置它才能实现我的问题的解决方案。我有一个用户表,假设我想检索所有具有FirsName = Will的用户。如何实现Map<String, Condition>?基本上,我不确定该在地图的Condition中放什么。

您可以在ScanCommandTest中找到示例用法。

对于条件FirstNameeqWill,滤波器可以类似于:

exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, new HashMap<String, Condition>(){{
put("FirsName", new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS("Will")));
}});

最新更新