Most Clojure NATS clients are thin wrappers around the official Java SDK (nats.java). That's a perfectly reasonable choice, but it comes with a JVM tax: you get nats.java's threading model, its option-builder classes, and a hard dependency on a full JVM, which means no runtimes like Babashka.
The NATS client protocol is a small, text-based, line-oriented protocol. claxon implements the protocol directly against a plain java.net.Socket, using plain Clojure data to describe the wire format with the following consequences:
bb.edn project, or embedded in a larger bb-based tool, with no AOT compilation and no native dependencies beyond the JVM/GraalVM that bb already ships.claxon.conf/defaults's :claxon/frame-shapes) ops, their arguments, and their payloads. Reading and writing frames are both generic interpreters over that data, not one function per operation. Additionally, the default protocol behaviour can be influenced and new things added, all from the userland.nats.java. The only third-party dependency is a JSON library (clojure.data.json on the JVM, nothing on bb), used only for INFO/CONNECT payloads.assoc-able data.claxon is deliberately a protocol client, not a full-featured NATS SDK. It doesn't try to be a drop-in replacement for nats.java's surface area, see Roadmap for what's intentionally left out for now.
Overall, all it does is:
INFO message and upgrade to TLS if necessary.PING and -ERR messages.some assembly required lib, trading off convenience over flexibility.| aspect | claxon | clj-nats | monkey-projects/nats |
|---|---|---|---|
| Underlying impl | Pure Clojure, raw sockets | Wraps nats.java | Wraps nats.java |
| Babashka compatible | Yes | No | No |
| User modifiable protocols | Yes | No | No |
| Dependencies | data.json on JVM, none on bb | nats.java + its transitive deps | nats.java |
| Protocol description | Data-driven | Delegated to nats.java | Delegated to nats.java |
The following are not yet implemented but planned (based on asks/issues) in order of priority:
INFO nonce yet.Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |