Example usage for com.amazonaws.services.dynamodbv2.document Table query

List of usage examples for com.amazonaws.services.dynamodbv2.document Table query

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.document Table query.

Prototype

@Override
    public ItemCollection<QueryOutcome> query(KeyAttribute hashKey, RangeKeyCondition rangeKeyCondition) 

Source Link

Usage

From source file:io.ignitr.dispatchr.manager.core.data.SubscriptionRepository.java

License:Apache License

/**
 *
 * @param topicName/*from  ww  w .ja  v a  2  s.co  m*/
 * @return
 */
public Observable<Subscription> findAllForTopic(String topicName) {
    return Observable.create(subscriber -> {
        Table table = dynamoDB.getTable(TOPIC_SUBSCRIPTIONS_TABLE_NAME);

        table.query("topic", topicName).forEach(item -> {
            Subscription metadata = new Subscription();
            metadata.setId(item.getString("subscriptionId"));
            metadata.setClientId(item.getString("clientId"));
            metadata.setTopicName(item.getString("topic"));
            metadata.setTopicArn(item.getString("topicArn"));
            metadata.setQueueArn(item.getString("queueArn"));
            metadata.setCreateDate(item.getLong("createDate"));
            metadata.setLastSubscribeDate(item.getLong("lastSubscribeDate"));

            subscriber.onNext(metadata);
        });

        subscriber.onCompleted();
    });
}