How to use client api in java application

Hi, are there any examples/docs how to use api provided by com.datomic:client-pro library? There is enough information about com.datomic:datomic-pro but nothing about client version. Actually I would know the entry point, if peer library has datomic.Peer class as entry point where I can start to use datomic, but I do not find anything similar in the client library

1 Like

@jaret @stu Could anyone please provide or point me any simple example of usage datomic client pro library in java app?

Or it is supposed that client pro library provides clj files which should used by java app directly like in the next example:

RT.loadResourceScript("datomic/client/impl/pro.clj");
            RT.var("datomic.client.impl.pro", "create-client").invoke(PersistentHashMap.create(Map.of(
                    Keyword.intern("server-type"), Keyword.intern("peer-server"),
                    Keyword.intern("access-key"), "datomic",
                    Keyword.intern("secret"), "datomic",
                    Keyword.intern("endpoint"), "localhost:8998",
                    Keyword.intern("validate-hostnames"), false)))

Looks like I was able to achieve some success result

If it is the right way of using client api in java app then I would ask about async api(since I’m interested in client api to be able to execute async queries) , I did small changes to the above example, but I’m getting an error:
“No implementation of method: :recent-db of protocol: #'datomic.client.impl.shared.protocols/Connection found for class: clojure.core.async.impl.channels.ManyToManyChannel”

It happens when

var db = fnDb.invoke(connection);
because connection is clojure.core.async.impl.channels.ManyToManyChannel when the same example is run but for sync api then class of connection is datomic.client.impl.shared.Connection

I highly recommend to use library mentioned here Client api for Java/Scala published - #3 by jaret

1 Like