An idiomatic & multi-platform Kotlin client for the NATS messaging system.
Warning
nats.kt is currently in active development!
Requires Kotlin 1.9 and Java 19 if you're using the JVM artifact.
- Latest Version: None
repositories {
maven("https://maven.dimensional.fun/releases") // or snapshots
}
dependencies {
implementation("fun.dimensional:knats-core:{VERSION}")
implementation("fun.dimensional:knats-jetstream:{VERSION}")
implementation("fun.dimensional:knats-micro:{VERSION}")
}
// create and connect a new NATS client.
val client = Client("nats://127.0.0.1:4222") {
// use the TCP transport, you could also use the WebSocket transport.
transport = TcpTransport
}
// create a subscription listening on all subjects.
val all = client.subscribe(">")
all.on<SubscriptionUnsubscribedEvent> {
println("Subscription was ${if (auto) "auto-" else ""}unsubscribed.")
}
all.on<SubscriptionDeliveryEvent> {
println("Received message $id on \"${delivery.subject}\"!")
}
more coming soon
Unless specified otherwise, all files are licensed under the Apache Version 2.0 license.