我使用Apache的駱駝使用以下路線定義試圖將消息從AWS SQS到AWS迪納摩DB:Apache的駱駝與AWS DynamoDB(AWS-DDB)的URI參數
<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>
但在執行駱駝抱怨該迪納摩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個未公開的參數時,我不能再重現此錯誤。
所以我的問題是:
- 爲什麼對PutItem請求AWS請求哈希關鍵數據?
- 爲什麼我無法再重現此行爲?
我在駱駝或AWS文檔中找不到任何提示,Google搜索只能發現一些不相關的結果。