Home > Net >  Thread blocked when calling dynamoDB in vert.x app
Thread blocked when calling dynamoDB in vert.x app

Time:02-10

I am using vert.x and I am trying to list my DynamoDB tables. Here is how I build the DynamoDB client.

private static DynamoDbAsyncClient buildDynamoDBAsyncClient(final Vertx vertx) {
        return VertxSdkClient.withVertx(DynamoDbAsyncClient.builder(), vertx.getOrCreateContext())
                .build();
    }

And here is the request I make

CompletableFuture<ListTablesResponse> response = client.listTables(ListTablesRequest.builder()
                .build());

        // Map the response to another CompletableFuture containing just the table names
        CompletableFuture<List<String>> tableNames = response.thenApply(ListTablesResponse::tableNames);

        // When future is complete (either successfully or in error) handle the response
        tableNames.whenComplete((tables, err) -> {
                if (tables != null) {
                    tables.forEach(System.out::println);
                } else {
                    // Handle error
                    err.printStackTrace();
                }
          
                client.close();
        });
        tableNames.join();

I get warnings of blocked threads and then a request timeout. What am I doing wrong? Thank you in advance.

CodePudding user response:

  •  Tags:  
  • Related