如何使用apachecamel扫描dynamodb表? [英] How to scan a dynamodb table using apache camel?
问题描述
我有一个可扫描 DynamoDb 表的骆驼休息 api.代码是这样的 ->
I have a camel rest api which scans a DynamoDb table. The code is like so ->
.post("dynamodb-scan-table")
.route()
.toD("aws2-ddb://user?accessKey=insert&secretKey=insert®ion=us-east-1&operation=Scan")
.endRest();
这将返回我表中的所有项目.我的问题是如何根据某个条件扫描表格.在骆驼 docs 中,给出了一个需要设置类型为 Map
的 header CamelAwsDdbScanFilter
以实现我的问题的解决方案.我有一个用户表,假设我想用 FirsName = Will
检索所有用户.我如何实现 Map
以实现这一目标?基本上我不确定在地图的 Condition
中放什么.
This returns all the items in my table. My problem is how to scan the table based on a certain condition. In the camel docs, it is given that there is a header CamelAwsDdbScanFilter
which is of the type Map<String, Condition>
needs to be set in order to achieve the solution for my problem. I have a table of users and suppose I want to retrieve all the users with FirsName = Will
. How do I implement the Map<String, Condition>
in order to achieve this? Basically I am not sure what to put in the Condition
of the map.
推荐答案
您可以在 ScanCommandTest.
对于条件 FirstName
eq Will
过滤器可能是这样的:
For condition FirstName
eq Will
the filter could be something like:
exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, new HashMap<String, Condition>(){{
put("FirsName", new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS("Will")));
}});
这篇关于如何使用apachecamel扫描dynamodb表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!