You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dev1 <jo...@wp.pl> on 2014/03/23 14:38:04 UTC

Camel AWS-DDB scan/query

Hello,
I'm using Camel AWS-DDB for the first time and have some issues getting data
from DynamoDB.

Could you, please, help me with this? I'm able to add some item, update by
primary Hash/Range key (by defining Key object) but is it possible to do it
by database indexes? 
I created some indexes on database with Hash/Range keys defined and could
not find any example of using them in camel. Is it possible to Query/Scan db
by indexes? How can I get list of items by value of some other field? I
tried CamelAwsDdbScanFilter but without success. 
Could you give me some examples of querying/scanning dynamoDB? 

Thanks in advance



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-AWS-DDB-scan-query-tp5749255.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel AWS-DDB scan/query

Posted by dev1 <jo...@wp.pl>.
And another question - is is possible to search only by Hash Key?

Thanks,
Patty



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-AWS-DDB-scan-query-tp5749255p5749564.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel AWS-DDB scan/query

Posted by dev1 <jo...@wp.pl>.
Could anybody help me with that?



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-AWS-DDB-scan-query-tp5749255p5749271.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel AWS-DDB scan/query

Posted by urbanenomad <ca...@urbanenomad.com>.
Sorry was this ever resolved?  I seem to be running into the same issue and
as I dig into the stack I notice that at line 39 and 40 of the class
org.apache.camel.component.aws.ddb.ScanCommand it seems to be over writing
the previous Result headers with the input headers and the only result that
survives is the last result value which is the DdbConstants.SCANNED_COUNT
value.  I can see that my scan call is receiving the items but it gets wiped
out in the outbound headers.

As I dig deeper it seems to be wiped out because the following lines of
code.

-------
package org.apache.camel.component.aws.common;

import org.apache.camel.Exchange;
import org.apache.camel.Message;

public final class AwsExchangeUtil {

    private AwsExchangeUtil() {
    }

    public static Message getMessageForResponse(final Exchange exchange) {
        if (exchange.getPattern().isOutCapable()) {
            Message out = exchange.getOut();
            *out.copyFrom(exchange.getIn());*
            return out;
        }
        return exchange.getIn();
    }
}
-------

The out.copyFrom(exchange.getIn()) method eventually clears the out.headers
which contained the last added header result info from the addToResult
method of the ScanCommand.

I think rather then doing the out.copyFrom, it just returned the out Message
then it would not get wiped and would return all the result information from
the ddb scan call.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-AWS-DDB-scan-query-tp5749255p5781695.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel AWS-DDB scan/query

Posted by dev1 <jo...@wp.pl>.
Thanks a lot for an answer!
I checked once more the documentation and still didn't get correct response.
I'm setting up the filter and - no answer. Headers I set:
"CamelAwsDdbScanFilter", "CamelAwsDdbAttributeNames"
Does the scanning really work for camel? 

Patty



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-AWS-DDB-scan-query-tp5749255p5749888.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel AWS-DDB scan/query

Posted by Bilgin Ibryam <bi...@gmail.com>.
The AmazonDynamoDB class used by Camel is deprecated, it might not support
all the new features offered by DDB.

The features offered by the camel component that can help you are: query
and scan. These operations call respectively the following methods of
AmazonDynamoDB:

public QueryResult query(QueryRequest queryRequest)

public ScanResult scan(ScanRequest scanRequest)


You can check the AWS API and see for yourself how to achieve what you want.

HTH,




On 23 March 2014 13:38, dev1 <jo...@wp.pl> wrote:

> Hello,
> I'm using Camel AWS-DDB for the first time and have some issues getting
> data
> from DynamoDB.
>
> Could you, please, help me with this? I'm able to add some item, update by
> primary Hash/Range key (by defining Key object) but is it possible to do it
> by database indexes?
> I created some indexes on database with Hash/Range keys defined and could
> not find any example of using them in camel. Is it possible to Query/Scan
> db
> by indexes? How can I get list of items by value of some other field? I
> tried CamelAwsDdbScanFilter but without success.
> Could you give me some examples of querying/scanning dynamoDB?
>
> Thanks in advance
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-AWS-DDB-scan-query-tp5749255.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Bilgin Ibryam

Apache Camel & Apache OFBiz committer
Blog: ofbizian.com
Twitter: @bibryam <https://twitter.com/bibryam>

Author of Instant Apache Camel Message Routing
http://www.amazon.com/dp/1783283475