Retrieved article excerpt
Open article · Retrieved 2026-11-24T18:23:06.676311+00:00
[Blog Home](https://developer.confluent.io/blog/)
Apache Kafka
# Using Agentic AI to create the next generation of non-Java Kafka clients
byAndrew Schofield, Principal Engineer, Apache Kafka committer and PMC memberNovember 24, 2026
Could AI tools help us generate a family of open-source non-Java clients directly from the Apache Kafka® source?
As I will explain, our experience suggests that they can - but only with a lot of work by engineers to get the right result.
Apache Kafka applications are written in many languages, but the Apache Kafka project itself provides only a [Java client](https://kafka.apache.org/44/javadoc/index.html).
The Apache Kafka project is moving fast with significant innovation constantly being delivered by more than 100 active contributors.
Each Kafka release typically has over 20 new KIPs, many of which touch the clients.
A significant proportion of Kafka applications are not written in Java.
In fact, Confluent Cloud - a managed Apache Kafka service - handles almost as many connections from non-Java clients across a variety of languages as it handles from Java clients.
Confluent's non-Java clients are built on top of a C library originally written by Magnus Edenhill called [librdkafka](https://github.com/confluentinc/librdkafka), which is almost as old as Kafka itself.
Client support for other languages such as Python and JavaScript is then layered on top of this C language core.
This has served the community well for over a decade.
There are Kafka clients from other groups too, some of which are built on librdkafka.
Python, JavaScript, .NET and other clients built on librdkafka, a C library which speaks the Apache Kafka protocol.
The difficulty is keeping the clients up to date and, historically, support for other languages has lagged behind.
The Apache Kafka client and librdkafka differ architecturally, including in threading, memory management, batching and buffering.
Those differences matter when tuning applications.
Advice for a Java client sending data to a topic with many partitions over high-latency connections cannot simply be applied to a JavaScript client built on librdkafka.
Because librdkafka is an entirely separate codebase, when a new feature arrives in Apache Kafka, it takes time before it is available in librdkafka.
Some features never arrive at all.
Keeping up with the increasingly rapid pace of Apache Kafka contributions required a new approach.
## The big idea
The big idea is to derive non-Java clients directly from the Apache Kafka Java client with the assistance of AI tooling.
We want:
- A modern, asynchronous core which can be used to build great clients for other languages
- Complete, sustained feature parity with Apache Kafka across all languages
- Consistent configuration and behaviour compared with the Java client
- More idiomatic APIs in all languages
- Great performance and efficiency
That’s quite a list.
Apache Kafka defines its programming interface in Java.
Python, JavaScript and golang are very different languages, from Java and from each other.
Concepts in Java such as inheritance and try-catch exception handling don't necessarily have direct equivalents in the other languages.
The central design challenge is to create natural programming interfaces for the other languages which preserve correspondence with Kafka’s Java interface without forcing the other languages to look like Java.
Instead, we need a set of rules mapping Java into the other languages so that they remain compatible as the Java client evolves.
Looking at Confluent's existing non-Java clients, we realised that it was necessary to evolve their interfaces too.
They were created before this approach to mapping between languages was considered.
The mapping rules must therefore handle not just today’s Java features, but features that have not yet been designed: the interfaces need room to grow naturally as those new features arrive.
Here’s a trivial example in Python.
In the librdkafka-based confluent-kafka-python, a consuming application receives a single Message or None from each call to Consumer.poll(timeout), and on each message, it must check whether an error occurred like this:
```
try:
consumer.subscribe(topics)
while running:
msg = consumer.poll(timeout=1.0)
if msg is None: continue
if msg.error():
raise KafkaException(msg.error())
else:
msg_process(msg)
finally:
consumer.close()
```
This doesn’t match the Kafka Java client at all well, because in Java KafkaConsumer.poll(Duration) returns ConsumerRecords and it throws KafkaException for errors.
As a result, we need to change the Python interface to have a similar shape which looks like this:
```
try:
consumer.subscribe(topics=topics)
while running:
records = consumer.poll(timeout=1.0)
for r in records:
msg_process(r)
finally:
consumer.close()
```
Why does this change matter?
Apache Kafka enhanced ConsumerRecords to improve offset tracking, and we want Python and the other languages to benefit from that enhancement.
The code snippet shows why correspondence with the Java interface matters: it leaves room to carry the same improvements into other languages.
Deriving the clients from Java is our approach to maintaining that link.
Looking at the huge strides which have been made in AI coding tools recently, we wanted to see whether we could perform translation from Java to create a new core for the derived clients, building a replacement for librdkafka which we could keep up to date with Apache Kafka more easily.
The code would remain owned by the engineers, but their productivity would be magnified through the use of AI.
The Apache Kafka Java client is translated by AI agents into a new client core, on which Python, JavaScript, .NET, Rust and other clients are built.
What we had in mind was a project with two distinct phases:
1. Translate the entire Java client at a known point
2. Continuously apply commits from Apache Kafka trunk to the translated codebase
To evaluate the approach, we decided to focus on the first of these phases.
We chose Rust as the target language and ran an engineering spike: a focused experiment to find out whether the translation approach was worth pursuing.
## Engineering spike
There are two tricks with an engineering spike.
First, attempt something bold and adventurous or you don’t need a spike at all.
Second, be prepared to fail fast if you discover that it’s all just a massive waste of time.
The Apache Kafka client is a large, complicated, multi-threaded piece of Java code.
It would take several weeks and a huge pile of tokens to translate its entirety into Rust.
We decided that we didn’t need to translate it all to start to get some answers.
We started with enough of the producer and consumer to give some meaningful performance numbers and skipped a lot of features we didn’t need to start with, such as transactions.
We were fairly new to using agent-based software development, although we did have experience of using AI for analysis and coding tasks.
We brought a lot of experience of the Apache Kafka codebase, librdkafka and the existing non-Java clients, and we developed our knowledge of Rust across the team as the spike progressed.
We started with Anthropic Claude® Opus 4.6, but as an indication of how fast this stuff moves, we upgraded several times as the new releases came out.
The spike ran for nearly three months, with two engineers each spending about 75% of their time on it.
We organised the work into two-week sprints, each with a target and an end-of-sprint review of progress and results.
Initially, the AI needed hands-on guidance: the agents asked many clarifying questions, some requiring research before we could answer properly.
We also had to manage expectations.
Even with AI, this work took time.
After two weeks, we had a working Kafka producer in Rust using insecure connections.
After two more, the producer supported TLS and authentication.
And after two more, we also had a basic consumer working.
There was a big list of restrictions, but it was possible to get some comparative performance measurements at this point.
We had also started to get an idea of the kind of things that the AI had got wrong.
Sometimes, it made mistakes.
Sometimes, the instructions were insufficient to get the desired outcome.
We even threw away the initial translation after a few weeks and tried again with tighter instructions.
This proved to be very worthwhile.
After three months, the performance measurements gave us confidence that a Rust core would be fast and efficient enough to do the job.
We had almost complete producer and consumer code in Rust and had tested it across a wide range of workloads.
There were still rough edges, but the results were promising.
To reach a decision on whether to proceed, we also evaluated other dimensions such as maintainability, extensibility and compatibility with the Java client interface.
As a proof of concept, we did a little work building a Python client on top of the Rust core, but there was a lot more work required here.
The spike answered a feasibility question.
It gave us confidence to proceed with the Rust core, while the derived clients still needed substantial work.
Keeping the translated codebase aligned with future Apache Kafka commits remained as future work.
The results were convincing and we made the decision to start the project to create the translated clients for real.
## The translation process
A common technique that people use with AI coding tools is known as “adversarial agents”.
You divide the work between agents which write the code, and agents which evaluate the code.
Our agents are called the Actor and the Critic, and there is also the Project Manager which orchestrates the other agents.
You can see the [prompts that we use for each agent type](https://github.com/confluentinc/kafka-clients/tree/master/.claude/agents), and the detailed [translation rules](https://github.com/confluentinc/kafka-clients/tree/master/.claude/rules).
The rules have [evolved](https://github.com/confluentinc/kafka-clients/commits/master/.claude/rules) significantly as the project has progressed.
It is slightly comical how the agent instructions everyone writes always start with a sentence like “You are an elite ...”.
I have no idea whether the flattery helps, but everyone does it.
The translation progresses in a three-level hierarchy: Milestones, divided into Phases, which may be divided into Layers.
The Project Manager agent makes different choices about how to structure each milestone.
Each translation milestone starts with a prompt, such as:
> The Producer should be able to accumulate messages into batches to produce in a Produce RPC.
Dependencies determine the order of the work.
The first milestone translates the leaves of the code’s dependency tree - the classes with no other dependencies — and later milestones build on the translated code they need.
Milestones that share dependencies but do not depend on each other can run in parallel.
Translation does not begin until a human has approved the milestone plan.
The Project Manager agent prepares that plan by analysing the requirements, identifying the classes to translate and their dependencies, and checking what already exists.
Where the plan involves design choices, it asks for guidance.
Java threads and Tokio tasks, for example, are not exact equivalents, so a human must guide the mapping.
Where we already know the required approach, we give the agent detailed instructions rather than leave the design choice open.
Milestone approval is followed by a second planning step.
The Project Manager agent creates a plan for each phase, and a human approves those phase plans too.
Translation begins only after the relevant phase plan has been approved.
The Project Manager agent starts the Actor and Critic agents and gives them the instruc