2

Current situation:

Clojure code -> Amazonica -> AWS Java SDK -> Standalone DynamoDBLocal.jar in background process over HTTP.

Desired situation:

Clojure code -> Amazonica -> AWS Java SDK -> In-process DynamoDB local

I managed to get the in-process DynamoDB to work, I can list tables (see below) but I don't know how to connect to it.

I tried looking at the AWS Java SDK docs and samples. Crickets.

The Amazonica docs shows only the :endpoint "http://localhost:8000" option (I'm using it currently).

Cognitect's AWS API also seems to support only the HTTP version via :endpoint-override.

Is what I'm trying to achieve even possible?

Here's the code I've got so far:

(import '(com.amazonaws.services.dynamodbv2.local.embedded DynamoDBEmbedded))
(.. DynamoDBEmbedded create amazonDynamoDB listTables)
=> #object[com.amazonaws.services.dynamodbv2.model.ListTablesResult 
   0x712e68f7 "{TableNames: [],}"]

Apart from the dependency itself I had to add the following to the alias in deps.edn

:jvm-opts ["-Djava.library.path=./DynamoDBLocal_lib"]

where DynamoDBLocal_lib contains the native libraries: libsqlite4java-osx.dylib / libsqlite4java-linux-amd64.so / sqlite4java-win32-x64.dll

P.S. I don't want to use Docker

akond
  • 15,865
  • 4
  • 35
  • 55
Jordan Biserkov
  • 647
  • 6
  • 13

1 Answers1

0

Have you tried DynamoDBEmbedded?

AmazonDynamoDB dynamodb = DynamoDBEmbedded.create().amazonDynamoDB();

for(String table : dynamodb.listTables().getTableNames()) {
    System.out.println(table);
}

dynamodb.shutdown();

You can find a fool code listing here, in aws-dynamodb-examples repo on GitHub. And here is another blog post with code samples.

madhead
  • 31,729
  • 16
  • 153
  • 201
  • Thanks! I did indeed try DynamoDBEmbedded and it works! My problem is how to make AWS Java SDK (or it's wrapper Amazonica) use that instead of the standalone one. – Jordan Biserkov Jul 29 '19 at 16:24