Task-first reference · JVM 3.3.2
CoAkka Runtime configuration · Java + Kotlin/JVM
Open only the group needed for the task. Kotlin samples use named arguments; Java uses the exact Java-friendly surface of the same connector. Read effective state from Core instead of reconstructing it from host input.
Build and dependencyChoose Maven or Gradle, not both
- Build JDK
- JDK 17 for the lessons. The connector's Java 8 consumer floor is separate from the JDK that runs the build tool.
- Maven
- Maven 3.9+; Java and Kotlin share
io.github.phuong-tran.coakka:runtime:3.3.2. - Gradle
- Java uses the application plugin; Kotlin uses Kotlin JVM
2.3.10. Both use toolchain 17. - Native Core
- The JAR carries an integrity-bound Core/JNI pair for packaged targets. The quick path needs no manual native library path.
Choose an owner APICoAkka.local · ConnectorOrchestrator
CoAkka.local(...)- Preferred Level 1 for learning, same-process handlers and plain-text request/reply.
LocalRuntime- Retains local targets, route generations and shutdown for the underlying owner. Never create one per request.
ConnectorOrchestrator- The public Level 2 name in the exact JVM
3.3.2JAR, used for explicit routes, networking, typed outcomes, Monitor and effective state. - Do not translate names across connectors
- Go, Node and Bun expose RuntimeHost names; JVM 3.3.2 does not. Do not invent an alias or trust a drifting sample.
Startup intentRuntimeStartSpec
systemName- Logical system or app-host name.
nodeId- Unique runtime-owner identity within that system.
routes- Initial route generation; local-first code can use
RuntimeClient.localRoutes(targets = ...). queueCapacity = 0- Asks Core to select and report its production default.
strictNoDrop = true- Keeps strict no-drop where supported; overload policy remains a separate contract.
generation- Initial control generation; stale updates must be rejected.
execution,io- Omit the whole group for Core-owned defaults and capability probes.
monitor = RuntimeMonitorOptions(enabled = true)- Permits collection before startup; reading a doorbell does not enable it.
Network, routes and endpointsRuntimeNetworkConfig · RuntimeRouteSpec
network = null- Preserves Core's Embedded default. Use explicit
embedded()when the lesson is teaching presence. outboundOnly()- Calls peers without owning an inbound listener.
networkNode(bindHost = …, bindPort = …, advertiseHost = …, advertisePort = …)- Bind and advertise are distinct facts; loopback is not reachable from another machine.
target- Business capability address; it stays stable when the handler moves to another process.
endpoints- Candidate owners with host, port, weight and flags.
SINGLE_OWNER- One owner;
WEIGHTED_ROUND_ROBINuses weights;RENDEZVOUS_HASHuses a route key. weight- Route-selection weight, not a retry count or priority.
LOCAL/UNAVAILABLE- Use exported contract values rather than assigning numeric meanings.
Connections and securityRuntimeTcpConnectionStrategySpec · RuntimeTcpSecuritySpec
connectionStrategy = null- Preserves Core's
MULTIPLEXINGdefault. A zero-valued object is explicit PER_EXCHANGE intent, not omission. mode- PER_EXCHANGE, BOUNDED_POOL, PERSISTENT_SINGLE_FLIGHT or MULTIPLEXING; inspect capability before choosing an optional mode.
maxConnections- Bounds connections when supported by the mode.
maxRequestsPerConnection- Bounds requests before Core retires a connection.
idleTimeoutMs- Bounds idle retention.
security.mode- PLAINTEXT, TLS or MUTUAL_TLS according to the trust boundary.
credentialGeneration- Nonzero and monotonic for a new credential set.
credentialId- Non-secret diagnostic identity; never place tokens or keys here.
caCertificateFile- PEM CA used to verify the peer.
identityCertificateFile/privateKeyFile- Instance identity chain and key; never log secret contents.
File Lane and Stream LaneIndependent owners
FileLane.openOwned- The receiver issues a grant pinned to one owner instance, address, port and transfer.
FileLane.sha256(path = ...)- Computes size and digest before prepare.
waitTransfer(..., afterUpdateSequence = ...)- Waits for a newer state; success requires COMPLETED, OK and a terminal receipt.
StreamLane.openOwned- The publisher issues a grant for one exact-owner session.
maxFrameBytes- Bounds each frame; the current public contract caps it at 4 MiB.
initialWindowBytes- Initial receive credit and at least one maximum frame.
StreamSource- Writes into the destination ByteBuffer only during the callback.
StreamConsumer- The data ByteBuffer is borrowed; copy before retention.
close()- Both lanes are independent synchronous-close owners after terminal or cancellation handling.
Read accepted and effective statestartupConfig · runtimeConfig · networkConfig
Create Configuration.kt beside the advanced files and run it with the chosen build tool.
Configuration.kt
import coakka.v2.connector.ConnectorOrchestrator
import coakka.v2.connector.RuntimeClient
import coakka.v2.connector.RuntimeMonitorOptions
import coakka.v2.connector.RuntimeNetworkConfig
import coakka.v2.connector.RuntimeStartSpec
import kotlinx.coroutines.runBlocking
fun main() = runBlocking {
val runtime = ConnectorOrchestrator.start(
startSpec = RuntimeStartSpec(
systemName = "config-lab",
nodeId = "config-lab-1",
queueCapacity = 64,
strictNoDrop = true,
routes = RuntimeClient.localRoutes(
targets = listOf("config.echo"),
),
network = RuntimeNetworkConfig.embedded(),
monitor = RuntimeMonitorOptions(enabled = true),
),
)
try {
val startup = runtime.startupConfig()
val accepted = runtime.runtimeConfig()
val network = runtime.networkConfig()
println(
"generation=${accepted.appliedGeneration} " +
"queue_capacity=${accepted.queueCapacity} " +
"strict_no_drop=${accepted.strictNoDrop} " +
"monitor=${startup.monitorEnabled} " +
"network_mode=${network.mode.value}",
)
} finally {
runtime.kotlin.shutdown()
}
}
Maven
mvn -q compile exec:java -Dexec.mainClass=ConfigurationKtGradle
gradle run -PmainClass=ConfigurationKtVerified output
generation=1 queue_capacity=64 strict_no_drop=true monitor=true network_mode=1
startupConfig()- Core-accepted default groups, execution, connection, I/O and Monitor facts.
runtimeConfig()- State, generation, routes, queues and effective overload facts.
networkConfig()- Mode, explicit-policy provenance and bind/advertise facts.
runtimeCapabilities()- Compiled, entitled and effective feature bits.
health()/stats()- Copied observed state and counters.