简体   繁体   中英

Connect AWS Dax Client to localstack DynamoDB?

I am attempting to use the AWS DaxClient to connect to a localstack setup running DynamoDB.

I start localstack from the docker-compose file in their github repo here .

Then I try creating a Dax Client in Java code and pointing it to that

public class PlainJavaClass {


    static AmazonDynamoDB daxClient;


    public static void main(String[] args) throws Exception {
        
        AmazonDaxClientBuilder daxClientBuilder = AmazonDaxClientBuilder.standard();
        daxClientBuilder.withRegion("us-east-1").withEndpointConfiguration("localhost:4566");
        daxClient = daxClientBuilder.build();

    }
}

However I'm getting the following exception:

12:36:53.713 [main] WARN com.amazon.dax.client.dynamodbv2.ClusterDaxClient - exception starting up cluster client: java.io.IOException: failed to configure cluster endpoints from hosts: [localhost:4566]
java.io.IOException: failed to configure cluster endpoints from hosts: [localhost:4566]
    at com.amazon.dax.client.cluster.Source$AutoconfSource.pull(Source.java:127)
    at com.amazon.dax.client.cluster.Source$AutoconfSource.update(Source.java:59)
    at com.amazon.dax.client.cluster.Source$AutoconfSource.refresh(Source.java:50)
    at com.amazon.dax.client.cluster.Cluster.refresh(Cluster.java:426)
    at com.amazon.dax.client.cluster.Cluster.refresh(Cluster.java:409)
    at com.amazon.dax.client.cluster.Cluster.startup(Cluster.java:330)
    at com.amazon.dax.client.cluster.Cluster.startup(Cluster.java:263)
    at com.amazon.dax.client.dynamodbv2.ClusterDaxClient.<init>(ClusterDaxClient.java:148)
    at com.amazon.dax.client.dynamodbv2.ClusterDaxClient.<init>(ClusterDaxClient.java:119)
    at com.amazon.dax.client.dynamodbv2.AmazonDaxClientBuilder.build(AmazonDaxClientBuilder.java:34)
    at com.example.crudspringbootdynamodb.PlainJavaClass.createDaxClient(PlainJavaClass.java:30)
    at com.example.crudspringbootdynamodb.PlainJavaClass.main(PlainJavaClass.java:50)
Caused by: com.amazon.cbor.EndOfStreamException: null
    at com.amazon.cbor.CborInputStream.readObject(CborInputStream.java:1340)
    at com.amazon.dax.client.exceptions.DaxServiceException.pickException(DaxServiceException.java:44)
    at com.amazon.dax.client.generated.DaxClientStubs.handleResponse(DaxClientStubs.java:963)
    at com.amazon.dax.client.generated.DaxClientStubs.endpoints_455855874_1(DaxClientStubs.java:479)
    at com.amazon.dax.client.dynamodbv2.DaxClient.endpoints(DaxClient.java:2375)
    at com.amazon.dax.client.cluster.Source$AutoconfSource.pullFrom(Source.java:137)
    at com.amazon.dax.client.cluster.Source$AutoconfSource.pull(Source.java:105)
    ... 11 common frames omitted
    Suppressed: com.amazon.cbor.EndOfStreamException: null
        ... 18 common frames omitted

I know I'm able to connect to localstack using a normal DynamoDb client created like this:

AmazonDynamoDBClientBuilder
                .standard()
                .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("http://localhost:4566/", "us-east-1"))
                .build();

So not really sure where to go next. Is it possible to use DAX client to connect to DynamoDB localstack?

No, localstack does not support it yet. There is an open issue about it on github ( https://github.com/localstack/localstack/issues/3707 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM