【发布时间】:2014-10-12 21:28:43
【问题描述】:
我正在尝试使用 Apache Camel 使用以下路由定义将消息从 AWS SQS 路由到 AWS Dynamo DB:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="aws-sqs://my_queue?accessKey=${aKey}&secretKey=RAW(${sKey})&maxMessagesPerPoll=10&deleteAfterRead=true"/>
<unmarshal>
<camel:json library="Jackson"/>
</unmarshal>
<to uri="aws-ddb:my_table?accessKey=${aKey}&secretKey=RAW(${sKey})&readCapacity=15&writeCapacity=100&operation=PutItem"/>
</route>
</camelContext>
但在执行时,Camel 抱怨 Dynamo Db URI 缺少一些必需的参数:
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: aws-ddb://table?amazonDDBClient=%23ddbClient&amazonDdbEndpoint=ap-southeast-2&readCapacity=10&writeCapacity=10 due to: Status Code: 400, AWS Service: AmazonDynamoDB, AWS Request ID: KHA79STK78SHC2BG2R8HLPF7RJVV4KQNSO5AEMVJF66Q9ASUAAJG, AWS Error Code: ValidationException, AWS Error Message: 2 validation errors detected: Value null at 'keySchema.hashKeyElement.attributeName' failed to satisfy constraint: Member must not be null; Value null at 'keySchema.hashKeyElement.attributeType' failed to satisfy constraint: Member must not be null
有趣的是,这两个参数在Camel DDB doc 的任何地方都没有描述。我花了一些时间浏览 Camel 源代码,发现了 2 个未记录的 URI 参数:keyAttributeName 和 keyAttributeType,这对我来说非常有效。 (我希望我的这个发现也能帮助别人)。
现在更有趣的是,在将项目插入 Dynamo DB 时不应该请求这些,但是当我从 URI 中删除 2 个未记录的参数时,我无法再重现此错误。
所以我的问题是:
- 为什么 AWS 为 PutItem 请求请求哈希键数据?
- 为什么我不能再重现这种行为?
我在 Camel 或 AWS 文档中都找不到任何提示,谷歌搜索只能发现少数不相关的结果。
【问题讨论】:
标签: amazon-web-services apache-camel amazon-dynamodb