简体   繁体   English

“DynamoDbException:请求了一个未知的操作。” 使用 LocalStack docker 容器、Java testcontainers 时的问题

[英]“DynamoDbException: An unknown operation was requested.” problem when using LocalStack docker container, Java testcontainers

I have application what uses DynamoDB.我有使用 DynamoDB 的应用程序。 I raise Dynamo with docker and work with it using DynamoDbClient.我使用 docker 提升 Dynamo 并使用 DynamoDbClient 使用它。 Actually, I have been using docker for dynamo for some time.实际上,我一直在使用 docker 作为 dynamo。 I used testcontainers lib and created GenericContainer with "amazon/dynamodb-local:latest" image.我使用了 testcontainers lib 并使用“amazon/dynamodb-local:latest”图像创建了 GenericContainer。 And all was fine.一切都很好。 But recently I started using other AWS technologies such as S3 and SQS, so I decided to use LocalStack Container for all this technologies.但最近我开始使用其他 AWS 技术,例如 S3 和 SQS,因此我决定将 LocalStack Container 用于所有这些技术。 Use the same clients and configuration.使用相同的客户端和配置。 And all is good with S3 and SQS, but Dynamo started failing on executeStatement method which process my PartiQL statments(it is important to me to use exactly PartiQL, not embedded methods in sdk for Java) with exception "DynamoDbException: An unknown operation was requested". S3 和 SQS 一切都很好,但是 Dynamo 开始在处理我的 PartiQL statments 的 executeStatement 方法上失败(对我来说完全使用 PartiQL,而不是 Java sdk 中的嵌入式方法很重要),出现异常“DynamoDbException:请求了未知操作”。 I cant understand where is the problem because I changed only docker container.我不明白问题出在哪里,因为我只更改了 docker 容器。 Here is me code for docker raising:这是我的码头工人代码:

private static final DockerImageName DOCKER_IMAGE_NAME = DockerImageName.parse("localstack/localstack")
            .withTag("latest");

GenericContainer<?> localStackContainer = new LocalStackContainer(DOCKER_IMAGE_NAME)
                .withServices(SQS, S3, DYNAMODB)
localStackContainer.start();

Configuration: (It is written on scala, but it's not important for this question) *Port in endpoint dynamically replaced with a docker-created port配置:(它是写在scala上的,但对于这个问题并不重要)*端点中的端口动态替换为docker创建的端口

dynamodb {
    region = "eu-central-1"
    endpoint = "http://localhost:4569"
    accessKeyId = "DEFAULT_ACCESS_KEY"
    secretAccessKey = "DEFAULT_SECRET"
    sessionToken = "DEFAULT_SESSION_TOKEN"
}

Client creating:客户端创建:

@Bean
    public DynamoDbClient dynamodb(final GlobalConfiguration globalConfiguration) {
        GlobalConfiguration.Dynamodb ddb = globalConfiguration.dynamodb();
        URI uri = URI.create(ddb.endpoint());
        Region region = Region.of(ddb.region());
        AwsBasicCredentials awsBasicCredentials = AwsBasicCredentials.create(ddb.accessKeyId(), ddb.secretAccessKey());
        StaticCredentialsProvider staticCredentialsProvider = StaticCredentialsProvider.create(awsBasicCredentials);
        return DynamoDbClient.builder()
                .endpointOverride(uri)
                .region(region)
                .credentialsProvider(staticCredentialsProvider)
                .build();
    }

Place where code fails:代码失败的地方:

dynamoDbClient.executeStatement(builder -> builder.statement(query));

Looks like localstack's DynamoDB implementation doesn't support PartiQL just yet .看起来 localstack 的 DynamoDB 实现还不支持 PartiQL Hopefully soon!希望不久!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Testcontainers 将可执行文件复制到 Docker 容器 - How to copy executable file to Docker container using Testcontainers java.sql.SQLException:不需要生成的密钥。 在JBoss - java.sql.SQLException: Generated keys not requested. in JBoss 从 Docker 连接到本地主机(Java 应用程序使用 mocking AWS 的 localstack) - Connecting to localhost from Docker (Java Application using localstack for mocking AWS) 无法使用 testcontainers 运行容器 - Unable to Run Container Using testcontainers 使用 TestContainers 和 Jenkins 在 docker 容器中运行测试(docker.sock 权限被拒绝) - Run tests in docker container using TestContainers and Jenkins (docker.sock Permission denied) 从 Java 使用 LocalStack 时获取 AmazonKinesisException 状态代码:502 - Getting an AmazonKinesisException Status Code: 502 when using LocalStack from Java 使用测试容器时“未找到可链接容器” - "linkablecontainer not found" when using testcontainers Postgres docker-compose 使用测试容器不起作用 - Postgres docker-compose using testcontainers not working Docker 容器上的 Java Runtime Exec 的问题 - The problem with Java Runtime Exec on Docker Container 在Testcontainers中使用自定义DB docker-image - Using custom DB docker-image with Testcontainers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM