Interface BatchGetResultPagePublisher
-
- All Superinterfaces:
org.reactivestreams.Publisher<BatchGetResultPage>
,SdkPublisher<BatchGetResultPage>
@ThreadSafe public interface BatchGetResultPagePublisher extends SdkPublisher<BatchGetResultPage>
Defines the result ofDynamoDbEnhancedAsyncClient.batchGetItem(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest)
operation.You can either subscribe to the
BatchGetResultPage
s or flattened items across all pages viaresultsForTable(MappedTableResource)
. Example:1) Subscribing to
BatchGetResultPage
sbatchGetResultPagePublisher.subscribe(page -> { page.resultsForTable(firstItemTable).forEach(item -> System.out.println(item)); page.resultsForTable(secondItemTable).forEach(item -> System.out.println(item)); }).exceptionally(failure -> { System.err.println("Failure occurred in subscription."); failure.printStackTrace(); return null; });
2) Subscribing to results across all pages.
CompletableFuture<Void> resultFuture1 = batchGetResultPagePublisher.resultsForTable(firstItemTable) .subscribe(item -> System.out.println(item)); CompletableFuture<Void> resultFuture2 = batchGetResultPagePublisher.resultsForTable(secondItemTable) .subscribe(item -> System.out.println(item)); resultFuture1.exceptionally(failure -> { System.err.println("Failure occurred in results for table " + firstItemTable); failure.printStackTrace(); return null; }); resultFuture2.exceptionally(failure -> { System.err.println("Failure occurred in results for table " + secondItemTable); failure.printStackTrace(); return null; });
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static BatchGetResultPagePublisher
create(SdkPublisher<BatchGetResultPage> publisher)
Creates a flattened items publisher with the underlying page publisher.default <T> SdkPublisher<T>
resultsForTable(MappedTableResource<T> mappedTable)
Returns a publisher that can be used to request a stream of results belonging to the supplied table across all pages.-
Methods inherited from interface software.amazon.awssdk.core.async.SdkPublisher
addTrailingData, buffer, doAfterOnCancel, doAfterOnComplete, doAfterOnError, filter, filter, flatMapIterable, limit, map, subscribe
-
-
-
-
Method Detail
-
create
static BatchGetResultPagePublisher create(SdkPublisher<BatchGetResultPage> publisher)
Creates a flattened items publisher with the underlying page publisher.
-
resultsForTable
default <T> SdkPublisher<T> resultsForTable(MappedTableResource<T> mappedTable)
Returns a publisher that can be used to request a stream of results belonging to the supplied table across all pages.This method is useful if you are interested in subscribing to the items in all response pages instead of the top level pages.
- Type Parameters:
T
- the type of the table items- Parameters:
mappedTable
- the table to retrieve items for- Returns:
- a
SdkPublisher
-
-