Situation
I am trying to write to DynamoDB using the Apache Camel aws2-ddb component . My route reads from a relational database using JPA, performs a transformation to the target class and puts that class into a DynamoDB table.
The target class looks like this (more complex in reality, of course)
@DynamoDBTable(tableName = "MyDataTable")
public class MyData {
private String key;
private String foo;
private List<String> bar;
@DynamoDBHashKey(attributeName = "key")
public String getKey() { return key; }
@DynamoDBAttribute(attributeName = "foo")
public String getFoo() { return foo; }
@DynamoDBAttribute(attributeName = "bar")
public List<String> getBar() { return bar; }
// ...
}
Using only the AWS SDK I would simply do something like this:
DynamoDBMapper mapper = new DynamoDBMapper(client);
mapper.save(myDataItem);
The aws2-ddb component however requires the item as a Map<String, AttributeValue>
.
Question
How can I transform the annotated class to Map<String, AttributeValue>
? It feels like this should be something obvious but I seem to be unable to find anything in the AWS SDK.
(As I workaround I could implement the above DynamoDBMapper
code in a custom processor, but I'd prefer to use the component.)
Unof.netelly during the camel-aws-ddb lib drill down, I found no possibility to use DynamoDbMapper. Basically, the aws-dbb / aws2-dbb components use DdbProducer under the hood which in fact is a Processor calling a ddbClient putItem in your case.
The possible options are:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.