Interface BatchGetResultPagePublisher

  • All Superinterfaces:
    org.reactivestreams.Publisher<BatchGetResultPage>, SdkPublisher<BatchGetResultPage>

    @ThreadSafe
    public interface BatchGetResultPagePublisher
    extends SdkPublisher<BatchGetResultPage>
    Defines the result of DynamoDbEnhancedAsyncClient.batchGetItem(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest) operation.

    You can either subscribe to the BatchGetResultPages or flattened items across all pages via resultsForTable(MappedTableResource). Example:

    1) Subscribing to BatchGetResultPages

     
     batchGetResultPagePublisher.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 Detail

      • 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