JDBC-style drivers for message brokers: one Java API, and one vocabulary, to inspect, operate and move messages on Apache Kafka, RabbitMQ and Apache ActiveMQ Artemis.
- One API, drivers found by
ServiceLoader. You program againstopenbroker-api, which depends on JSpecify only; a driver on the class path plugs in like a JDBC driver, and a conformance kit (the TCK) proves each one against a real broker. - Operations are previewed first. A preview states the change, an estimate and an etag;
execute(…, Precondition.ifMatch(etag))refuses if the resource changed in between. - Results are honest. A cluster-wide call returns a
Partialnaming each node's outcome. An error is aBrokerExceptionwith a status, a reason, and whether the request was sent.
| System | Driver artifact | Supported versions | Tested by the TCK in CI |
|---|---|---|---|
| Apache Kafka | openbroker-kafka |
2.8 and later | 3.0, 3.9, 4.0 and 4.4 (2.8 is covered by an integration test in CI, not by the TCK) |
| RabbitMQ | openbroker-rabbitmq |
3.13 and later | 3.13 and 4.4 |
| Apache ActiveMQ Artemis | openbroker-artemis |
2.33 and later | 2.33 and 2.57 |
Status: pre-1.0 (0.x). The API may change between minor versions until 1.0.
Use the version the Maven Central badge shows; 0.16.0 below was the latest at the time of writing.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.github.sudoitir</groupId>
<artifactId>openbroker-bom</artifactId>
<version>0.16.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.github.sudoitir</groupId>
<artifactId>openbroker-api</artifactId>
</dependency>
<dependency>
<groupId>io.github.sudoitir</groupId>
<artifactId>openbroker-artemis</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>try (BrokerDrivers drivers = BrokerDrivers.load();
ClusterConnection cluster = drivers.connect(new ConnectRequest(
"artemis",
ClusterSpec.ofNodes(List.of(new NodeSpec(
NodeId.of("primary"),
List.of(
Endpoint.of(Plane.MANAGEMENT, "jolokia", "http://broker:8161/console/jolokia"),
Endpoint.of(Plane.DATA, "core", "tcp://broker:61616"))))),
CredentialSource.of(Credentials.usernamePassword("admin", System.getenv("BROKER_PASSWORD"))),
ConnectOptions.defaults()))) {
// Every subscription (an Artemis queue) with its backlog, on every node.
Partial<ResourcePage> page = cluster.resources().read(ResourceQuery.of(ResourceClass.SUBSCRIPTION));
for (Resource r : page.orThrow().items()) {
// A backlog is exact, an estimate, or not reported; a missing value is never shown as zero.
String backlog = r.attributes().get(MetricKeys.BACKLOG)
.map(v -> (v.precision() == Precision.EXACT ? "exact " : "estimate ") + v.asLong())
.orElse("unavailable");
System.out.println(r.id() + " " + backlog);
}
// Send one message to a destination (an Artemis address).
cluster.messages()
.send(
SendTarget.destination(ResourceId.of("artemis.address", "orders")),
OutboundMessage.of(MessageBody.of("hello".getBytes(StandardCharsets.UTF_8))));
}The other drivers connect the same way, and only the endpoints differ (the kinds a system offers are read
from cluster.resources().kinds()). A Kafka cluster is reached on its data plane:
ConnectRequest kafka = new ConnectRequest(
"kafka",
ClusterSpec.ofNodes(List.of(new NodeSpec(
NodeId.of("1"),
List.of(Endpoint.of(Plane.DATA, "kafka", "broker-1:9092"))))),
CredentialSource.none(),
ConnectOptions.defaults());A RabbitMQ node is reached on its management plane (HTTP API) and its data plane (AMQP 0-9-1), and its id is the Erlang node name:
ConnectRequest rabbitmq = new ConnectRequest(
"rabbitmq",
ClusterSpec.ofNodes(List.of(new NodeSpec(
NodeId.of("rabbit@rabbit1"),
List.of(
Endpoint.of(Plane.MANAGEMENT, "http", "http://rabbit1:15672"),
Endpoint.of(Plane.DATA, "amqp", "rabbit1:5672"))))),
CredentialSource.of(Credentials.usernamePassword("admin", System.getenv("BROKER_PASSWORD"))),
ConnectOptions.defaults());These are the requests the driver tests build against real clusters
(KafkaTestCluster,
RabbitMqTestCluster).
- Resources are read by class (
DESTINATION,SUBSCRIPTION,CONSUMER, …) or by a system's kind (artemis.queue), with standard attributes and metric keys (openbroker.backlog, …). - Operations are previewed before they run: a preview states the change, an estimate and an
etag;
execute(…, Precondition.ifMatch(etag))refuses if the resource changed in between. - Results are honest. A cluster-wide call returns a
Partialnaming each node's outcome. An error is aBrokerExceptionwith a gRPC status, a reason, and whether the request was sent. - What only one system has is reached through
cluster.unwrap(…): for ArtemisArtemisManagement, for Kafka itsAdminclient. The connection owns theAdmin; closing the view it hands out does nothing, and its calls bypass theCallInterceptor.
| Artifact | What it is |
|---|---|
openbroker-api |
The API you program against, and the driver SPI. Depends on JSpecify only. |
openbroker-support |
Shared helpers for drivers and consumers: the portable filter dialect, polling notifications, counter rates. |
openbroker-tck |
Abstract JUnit contract tests a driver extends. |
openbroker-artemis |
The Apache ActiveMQ Artemis driver: management over Jolokia, messages and notifications over Core. |
openbroker-kafka |
The Apache Kafka driver (2.8 and later): management over Admin, messages over the producer, consumer and share consumer. |
openbroker-rabbitmq |
The RabbitMQ driver (3.13 and later): management over the management HTTP API, messages over AMQP 0-9-1. |
openbroker-opentelemetry |
Optional: maps the messaging observer to OpenTelemetry spans, metrics and W3C trace context. |
openbroker-spring-boot-starter |
Optional: everything a Spring Boot 4 application needs; add the drivers it uses. |
openbroker-spring-boot-autoconfigure |
Optional: the auto-configuration behind the starter. |
openbroker-bom |
Aligns the versions above. |
Java 25. The modules ship module-info descriptors (the driver an Automatic-Module-Name).
cluster.transport() is a messaging client with stated guarantees. A link declares its guarantee and
the driver refuses what it cannot keep (UNIMPLEMENTED). Sending is bounded, receiving is
credit-based, and a lost link is recovered by the driver under the rules below.
Transport transport = cluster.transport().orElseThrow();
ResourceId orders = ResourceId.of("artemis.address", "orders");
ResourceId deadLetters = ResourceId.of("artemis.address", "orders.dead");
// At-least-once with deduplication: resends after a failure are deduplicated, in order.
SenderOptions sending = SenderOptions.defaults().withDeduplication(DeduplicationScope.SESSION).withOrdering(OrderingScope.GROUP);
try (Sender sender = transport.sender(SendTarget.destination(orders), Scope.whole(), sending)) {
OutboundMessage message = OutboundMessage.of(MessageBody.of(payload))
.withHeaders(MessageHeaders.builder().groupId("customer-7").build());
// offer never blocks; Full says the bounded send buffer has no room.
switch (sender.offer(message)) {
case Offer.Accepted accepted -> accepted.receipt().thenAccept(receipt -> log(receipt.resent()));
case Offer.Full full -> slowDown(full.inFlight(), full.bufferedBytes());
}
sender.send(message); // waits for room (up to maxBlock) and for the confirmation
sender.flush(Duration.ofSeconds(10));
}
// Eight lanes on virtual threads; one group runs in order; the client retries up to 5 times.
ProcessorOptions processing = ProcessorOptions.defaults()
.withConcurrency(8)
.withOrdering(OrderingScope.GROUP)
.withRetry(RetryPolicy.managed(5, Backoff.defaults()).withDeadLetter(SendTarget.destination(deadLetters)));
try (Processor processor = transport.process(
ResourceId.of("artemis.queue", "orders"), Scope.whole(), processing, context -> {
handle(context.message());
return Disposition.accept(); // an exception or Release counts as a failed attempt
})) {
awaitShutdown();
}Telemetry is a hook. Add openbroker-opentelemetry and pass the observer when connecting:
ConnectOptions options = ConnectOptions.defaults().withObserver(OpenTelemetryMessaging.of(openTelemetry));| Guarantee | Link lost | Broker restart, no HA | Failover to a backup | Client dies | Answer lost |
|---|---|---|---|---|---|
AT_MOST_ONCE send |
unconfirmed may be lost, never resent (UNAVAILABLE, IN_DOUBT) |
non-durable lost | unconfirmed may be lost | buffered lost | n/a |
AT_MOST_ONCE receive |
prefetched and handed-out lost | same | same | same | n/a |
AT_LEAST_ONCE send |
resent in order: no loss, duplicates possible (resent=true) |
confirmed survive; unconfirmed resent | same | unconfirmed in the buffer lost | resent: duplicate possible |
AT_LEAST_ONCE send, deduplicating |
resent and deduplicated: no loss, no duplicate, order kept | same, within the dedupe window | same | as above | resent and deduplicated |
AT_LEAST_ONCE receive, process |
unsettled redelivered; a stale settle fails DELIVERY_STALE |
redelivered | redelivered | redelivered | redelivered: duplicate |
TRANSACTED, joined included |
rolled back; commit fails ABORTED; redo |
rolled back | rolled back | rolled back | IN_DOUBT; redo with the same dedupe ids |
After giveUpAfter a link is FAILED: pending receipts fail UNAVAILABLE, IN_DOUBT, and nothing is
resent. The dedupe window is reported by Sender.deduplication().
openbroker-kafka supports Apache Kafka 2.8 and later, in ZooKeeper and KRaft mode, and refuses an older
cluster when it connects. It uses kafka-clients alone. What a cluster lacks is declared per feature, with
its reason, and never emulated:
| Capability | Needs | Otherwise |
|---|---|---|
kafka.quorum |
KRaft mode | The quorum is not described; node health carries no voter state |
kafka.consumer-protocol-groups |
Kafka 4.0 with group.version 1 |
Processors join with Kafka's classic protocol and its cooperative assignor |
kafka.share-groups |
Kafka 4.2 with share.version 1 |
The share-group kind is not declared |
kafka.streams-groups |
streams.version 1 |
Streams groups are not listed |
kafka.fenced-brokers |
KRaft and Kafka 4.0 | A fenced broker is missing from the nodes instead of shown as fenced |
kafka.eligible-leaders |
eligible.leader.replicas.version 1 |
Partitions carry no kafka.elr attributes |
kafka.transaction-listing |
Kafka 3.0 (ListTransactions, KIP-664) |
Transactional ids are listed from the coordinator; hanging transactions are not, and their kind is not declared |
verify checks every broker on the address it advertises, in parallel and within the connect timeout, and
names each unreached broker and why (the name does not resolve, the connection is refused or times out, TLS
or authentication fails). A cluster below Kafka 3.3 reports no metadata.version, so its release is named by
the API keys it serves (DescribeProducers arrived in 2.8, ListTransactions in 3.0), read from the wire
because the Admin API exposes no version table (ADR-0032).
- Resources. Brokers are nodes; topics, partitions, consumer groups, share groups, ACLs and
transactional ids are kinds. Streams groups, and classic groups run by Kafka Streams, are listed
read-only, because their offsets belong to the applications that run them. Changes are watched by polling, every
watch.interval(ten seconds by default), including consumers joining and leaving a subscription. - Lag and counts are estimates. Offset arithmetic overcounts on compacted and transactional topics, so every total says so.
- Destructive operations are honest. Purge and seek reset a group's committed offsets and fail
FAILED_PRECONDITIONwhile the group has members or is rebalancing, without removing them; an empty classic group can be rewound too. Truncate deletes records before an offset, with a preview, and is refused on a compacted topic. Moving, copying or deleting one message is unavailable, because a log cannot remove one record. - Hanging transactions (
kafka.hanging-transaction) are transactions the coordinator no longer tracks, open on a partition for longer thantransaction.max.timeout.ms, which hold its last stable offset back so thatread_committedconsumers stall (KIP-664). They are listed on demand, never on the watch, for the cluster or one topic, andRESOLVEaborts one, previewing the records it holds back. A transaction the coordinator still lists heals itself and is not listed. - Broker configuration (
kafka.broker-config, classCONFIGURATION) is one resource per broker and*for the cluster-wide default. Settings arekafka.config.<name>attributes, never a secret;kafka.config_read_onlynames those only a restart changes andkafka.config_sourceswhere each override comes from.UPDATEpreviews the change and applies a dynamic setting; a read-only or secret setting is refused before anything is sent. - Browsing reads committed records without joining a group.
- Messaging. Senders deduplicate within the producer session (
DeduplicationScope.SESSION). Processors on a consumer or classic group settle by committing offsets, keep per-key order in lanes, and join transactions (KIP-447). A retry that is ordered, transacted or the default happens in place; an explicitly managed, unordered policy uses one retry topic per backoff step (<topic>.retry-<n>). Exhausted records go to<topic>.dlt. The processor refuses to open when a retry or dead-letter topic is missing and the account cannot create it. - Share groups (Kafka 4.2 and later) are their own subscription kind: settlement per message, no
ordering, at least once only, and the processor renews a record's lock while a slow handler runs.
The broker counts attempts, so the default policy is the system's. From Kafka 4.4 with
share.version2, the broker dead-letters to the group's configured topic; atshare.version1 a record past the delivery limit is archived with no copy, so choose a managed policy when you need the dead letter. - Security. SASL (PLAIN, SCRAM, OAUTHBEARER with a refreshed bearer token), TLS and mutual TLS
(
Credentials.None). Hostname verification stays on.
openbroker-rabbitmq supports RabbitMQ 3.13 and later, read from the management API's rabbitmq_version, and
refuses an older cluster when it connects. It manages the cluster through the management HTTP API and moves
messages over AMQP 0-9-1 with amqp-client; it needs no stream-protocol port.
A connection has one or more management endpoints (http or https, a base URL with an optional path prefix)
and, for messages, one or more data endpoints (amqp or amqps, host:port). Without a data endpoint the cluster
is read and changed, and every messaging capability says it needs one. The options are rabbitmq.watch_interval
(how often the polling watch and the queue-type cache refresh) and rabbitmq.event_vhost (the virtual host the
event-exchange queue lives in).
- Mapping. A virtual host is a namespace; an exchange a destination; classic queues, quorum queues and streams are three subscription kinds, because their verbs differ; bindings, exchange-to-exchange bindings, shovels and federation links are routes; policies and operator policies are policies; permissions and topic permissions are access rules; connections, channels and consumers are clients. Quorum and stream members are leader and follower placements, marked in sync or not.
- Browse never consumes. Only a stream is browsed, from an offset (
x-stream-offset), and the messages stay where they are. Browsing a classic or quorum queue is refusedNOT_SUPPORTEDbefore any call: a get and requeue would change delivery counts, redelivery flags and order. - Sends are confirmed and routed. Every send uses publisher confirms and
mandatory; a message the broker routed to no queue failsNOT_ROUTED(ADR-0035). - Etags say what they can tell apart. RabbitMQ has no incarnation id, so every preview's basis is
CONFIGURATION: a resource deleted and created again with the same configuration is not told apart (ADR-0034). - Destructive operations are honest. Purge empties a classic or quorum queue's ready messages; a stream has no purge. A quorum queue or stream is deleted only after the driver has checked the emptiness or unused condition the broker does not enforce for it. Shovels, federation upstreams and users carry secrets the SDK cannot yet accept write-only, so they are read and deleted, never created.
- Counts are estimates where the management statistics are sampled, and say so.
- A crash right after a queue is declared. RabbitMQ writes a new quorum queue's membership to disk about every half second, so a whole-cluster crash within that window can lose the queue's members and the messages it had confirmed. That is the broker's behaviour, not the driver's; a queue that has been in use is not affected.
- Events come from the event exchange (
rabbitmq_event_exchange) when it is enabled and the account may bind to it, and from a polling watch otherwise; thenotificationscapability says which. - Messaging. Receivers consume with manual acknowledgements and
basic.qos; settlement is by acknowledgement, with no transacted batch. The client's own recovery is off: links are reopened by the SDK's supervisor, and a settlement after a channel was lost failsDELIVERY_STALE.
openbroker-spring-boot-starter gives a Spring Boot 4 application its OpenBroker clients as beans. It is the
only place Spring appears: the API and the drivers stay framework-free, and the build enforces it.
<dependency>
<groupId>io.github.sudoitir</groupId>
<artifactId>openbroker-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.github.sudoitir</groupId>
<artifactId>openbroker-kafka</artifactId>
</dependency>- Nothing to configure when Spring Boot already knows the broker. With a Kafka or Artemis driver on the
class path,
spring.kafka.*,spring.artemis.*,@ServiceConnectionor Docker Compose give a connection namedkafkaorartemis, with its endpoints, security protocol, SSL bundle and (for KafkaPLAINandSCRAM-*) the login fromsasl.jaas.config. Spring states no Artemis management endpoint, so its management facets stay unavailable, and its health isUNKNOWN, until you add one. Anopenbroker.connections.<name>of the same name is laid over the derived connection key by key (nodes merge by id, other lists replace), andopenbroker.spring-connections.enabled=falseturns derivation off. - Connections in
application.yml. Eachopenbroker.connections.<name>binds the SDK's own records (SenderOptions,ProcessorOptionsand the rest) over their own defaults, so setting one key keeps every other default. Credentials name their form. TLS comes from a Spring SSL bundle (options.ssl-bundle), read again on every connect, so a reloaded bundle reaches the next connection.
openbroker:
client:
connect-timeout: 5s
connections:
orders:
system: kafka
cluster:
cluster-endpoints:
- { plane: data, protocol: kafka, address: "broker-1:9093" }
- { plane: data, protocol: kafka, address: "broker-2:9093" }
options:
security.protocol: SASL_SSL
sasl.mechanism: SCRAM-SHA-512
credentials:
form: username-password
username: orders-app
password: ${ORDERS_PASSWORD}
options:
ssl-bundle: kafka
sender:
guarantee: at-least-once
processor:
concurrency: 4
billing:
system: artemis
cluster:
nodes:
- id: primary
endpoints:
- { plane: management, protocol: jolokia, address: "http://artemis:8161/console/jolokia" }
- { plane: data, protocol: core, address: "tcp://artemis:61616" }
credentials:
form: username-password
username: billing-app
password: ${BILLING_PASSWORD}- Beans by name. Each connection is a
ClusterConnectionand aTransportbean (ordersClusterConnection,ordersTransport), qualified by its name and primary when it is the only one. Your own bean of the same name wins. ACredentialSourcebean qualified with the connection's name wins over its credentials. A wrong connection (a misspelt option, a value out of range, a missing driver, a dead-letter target in YAML) fails the start naming the connection and the key, never a value. - Runtime connections. An application that opens connections from its own store gets the same pieces:
the
BrokerDriversbean,OpenBrokerConnectOptions.forConnection(name, system, tls)(your interceptor, clock, observers andConnectOptionsCustomizers over theopenbroker.client.*defaults) andSslBundleTls.forBundle(...). Health and the processor lifecycle are not applied to them. - Health, metrics, tracing. With Actuator,
openbrokerhealth has one indicator per connection: up while the cluster describes its nodes (a partial answer counts), down with the reason otherwise, with a deadline (openbroker.health.timeout) and at most one check at a time; the first check ever isUNKNOWN, not down, if it passes the deadline. Metrics go to Micrometer when aMeterRegistryis present and spans to OpenTelemetry when anOpenTelemetrybean is; with both, nothing is counted twice. Metrics are tagged with the connection, system and operation, not the destination (too many distinct values); spans carry it.openbroker.tracing.inject-context=falsestops sends writing trace context into the message, for tools that relay messages other producers wrote. - Lifecycle. Register processors with
OpenBrokerProcessors: they start when the application is ready (after its runners) and stop within theirstopGracebefore any connection closes; the drivers close last.
A driver implements io.github.sudoitir.openbroker.spi.BrokerDriver and is registered in
META-INF/services/io.github.sudoitir.openbroker.spi.BrokerDriver. It declares its kinds, capabilities and
connection options, and extends the TCK's contract tests with a TckEnvironment for a real broker. The guide
is docs/writing-a-driver.md; openbroker-artemis is the reference.
The design is recorded in docs/adr/; the index lists every decision in order.
Apache ActiveMQ, ActiveMQ Artemis and Artemis are trademarks of the Apache Software Foundation. Other broker names are trademarks of their owners. OpenBroker is not affiliated with or endorsed by them; it names them only to say which systems it works with. See NOTICE.
Licensed under the Apache License 2.0.