I don't think there is a native way to specify conditionExpression in the
UpdateItem producer operation, at the moment

https://github.com/apache/camel/blob/608122ac13573352313d665dbaccf9fdb253e89e/components/camel-aws/camel-aws2-ddb/src/main/java/org/apache/camel/component/aws2/ddb/UpdateItemCommand.java#L35

Il giorno gio 18 nov 2021 alle ore 06:33 sagarcasual <sagarcas...@gmail.com>
ha scritto:

> versions used Java 13, Apache Camel 3.11.2, AWS SDK 2.17.40.
>
> Seeking help to perform conditional update to dynamodb using Apache Camel
> integration lib.
>
> Table Definition=================
> PKCOL String, primary-key
> COL1  String
> COL2  String
>
> I would like to issue following SQL Equivalent statement using native
> Apache Camel Dynamodb component
>
> UPDATE tableName  SET PKCOL = :PKCOLValue, COL1 = :COL1Value, COL2 =
> :COL2Value //Update expression
> WHERE //Conditional Expression below
> (PKCOL = :PKCOLValue AND COL2 < :thresholdValue)
> OR
> (attribute_not_exists(PKCOL) OR attribute_not_exists(COL1) OR
> attribute_not_exists(COL2))
>
> However I am not able to see a direct mapping for update expression, place
> where I can stick in ORs and ANDs clauses
>
> I am able to use combination of aws sdk2 for dynamodb and bean route to get
> it done as seen below,
>
> final UpdateItemRequest request = UpdateItemRequest.builder ()
>                                  .tableName (tableName)
>                                  .key (itemKey) //PKCOL key, value map
>                                  .updateExpression (updateExpression)
> //SET expression clause in query above
>                                  .conditionExpression
> (conditionExpression) //Muli conditional statement after where clause
> in query above
>                                  .expressionAttributeValues
> (expressionAttributeValues) //Value map for all columns
>                                  .returnValues (ReturnValue.UPDATED_NEW)
>                                  .build ();
>
> exchange.getIn ().setBody (request, UpdateItemRequest.class);
>
> bean (DynamoDbClient.class, "updateItem(${body})")
>
> But I am interested in native camel way, hence seeking help.
>

Reply via email to