# Using Agentic AI to create the next generation of non-Java Kafka clients

> Source: <https://developer.confluent.io/blog/using-agentic-ai-to-create-non-java-clients/>
> Published: 2026-11-24 00:00:00+00:00

**Recommendation:** When using coding agents to port a fast-moving codebase, define explicit source-to-target mapping rules that accommodate undesigned features, and plan for heavy engineer review rather than accepting generated output as-is.
More in the playbook "Working with AI coding agents": <https://wpnews.pro/playbooks/coding-agents>

[Blog Home](https://developer.confluent.io/blog/)

# Using Agentic AI to create the next generation of non-Java Kafka clients

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.

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.

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 instructions. The Actor and Critic agents communicate via git and take turns to run.

First, the Actor agent performs the translation tasks, makes sure the code builds cleanly, and passes the linter and the tests. It summarises what it did and commits the changes to git.

Next, the Critic agent evaluates the changes and creates a file containing its review comments and commits that to git.

The Actor agent then reads the Critic agent’s comments, resolves them, records the resolutions in a file and commits the changes to git. The two agents repeat this review-and-fix cycle until the Critic agent has no further comments. The loop typically runs about 5 iterations, sometimes more, sometimes less.

At the end of each phase, the Project Manager agent updates the status, copies the history of what the agents did, and starts the next phase if there is one.

If you’re interested in the detail of the actual milestones, you can see the [history](https://github.com/confluentinc/kafka-clients/tree/master/design/history).

## Some things we learnt along the way

While Apache Kafka has a lot of tests, they are a very long way from being a specification of every aspect of the required behaviour.

When translating the Kafka code, we also translated the tests. Just because the translated tests passed did not mean the translated code behaved sensibly. For example, while we got working code extremely quickly, the initial performance runs were very slow. When we investigated, we found a sleep on every iteration of the networking loop. The translated tests passed despite that choice. Performance testing exposed a problem that those tests did not catch.

The Java client is multi-threaded and in some cases shares data between threads. We used Tokio tasks instead of threads, but they’re not exactly the same, so we needed more detailed instructions to get the correct effect. Now future translation in that area benefits from the additional guidance.

These learnings changed how we approached the translation. We needed instructions that explained the intended behaviour, not just the source code to translate, and checks that went beyond passing translated tests. Throwing away the initial translation and starting again with better instructions was worthwhile because a better translation had fewer issues to resolve.

When we moved from Apache Kafka 4.3.1 to 4.4.0, we decided to apply the changes which had been made to Kafka to our translated code, rather than translate everything again. It took less than 2 working days to apply 191 commits which represent several months' changes.

The most important lesson is that the quality and specificity of the instructions has a very strong bearing on the quality of the output. We didn't really test variations of the translation rules as such, but we did refine them as it became clear which details we needed to include to get what we wanted.

## The Rust client interface

While the AI was great at generating the translated code, the design of the Rust client interface was an area where the humans took over.

Designing the Rust interface took several iterations of experimentation and discussions with Rust experts. A direct mapping from Java was not enough: Java has inheritance, polymorphism, exceptions and threads, while Rust prioritises performance and memory safety. Those differences shaped the interface we developed. It may still benefit from further refinement as more people try it out.

At a superficial level, there is quite a close resemblance between simple Kafka applications in Java and Rust as a result of the translated naming. For example, here’s a snippet of a Rust producer that connects to a cluster and sends a record to a topic.

``` js
let props = HashMap::from([
    ("bootstrap.servers".to_string(), "localhost:9092".to_string()),
]);
let config = ProducerConfig::new(&props)?;

let producer = KafkaProducer::<String, String>::new(config,
    StringSerializer::new(), StringSerializer::new())?;

let record = ProducerRecord::with_key("my-topic".to_string(),
    Some("key".to_string()), Some("value".to_string()));

producer.send(record).await?.get().await?;
producer.close().await?;
```

The names of the types largely match what a Java programmer would expect. The await? looks a bit strange - it waits for an asynchronous operation and propagates any error. Used correctly, it’s a very compact equivalent of exception handling.

The Java client uses method overloading such as the variants of KafkaProducer.send(...). In Rust, these are separate functions:

```
fn send(&self, record: ProducerRecord<K, V>)

fn send_with_callback(&self, record: ProducerRecord<K, V>,
                      callback: Option<Box<dyn Callback>>)
```

Error handling shows why we could not simply copy Java’s type structure. Java represents different error codes through subclasses of KafkaException, including TopicAuthorizationException and GroupIdNotFoundException. We could not map that hierarchy satisfactorily into Rust types, so we use a flat enum called Error, with variants such as Error::TopicAuthorization and Error::GroupIdNotFound. Predicates such as is_retriable_error provide the information that Java exposes through its class hierarchy. Functions return Result<T, Error>, giving Rust callers an idiomatic way to handle errors and propagate them with await?.

## Creating the Rust core for real

The aim of the translation was not just to convert the Java client into a Rust client. We wanted the Rust code to serve two purposes: a client that Rust programmers could use directly, and a core on which we could build clients for languages such as Python. Those are different interface-design problems.

The Rust client needs an interface which looks natural to Rust programmers (but which also has a direct correspondence with the Apache Kafka Java client), while the Rust core should have an interface which is efficient for inter-language calls (and which lets derived clients implement the behaviour of the Java client faithfully).

Here are some examples of when the Rust core diverges from a simple translation.

1. 
The derived clients must serialize and deserialize the records themselves. For example, each derived language will have its own way of representing strings. The Rust core exposes optimised producer and consumer methods which pass the records as simple arrays of bytes, and then the serializers and deserializers in the derived clients can do the right thing for their languages.
2. 
Waiting inside the Rust core should generally be avoided because it interferes with signal handling in the derived language’s runtime. A Python producer still needs to pass records efficiently, respect timeouts and remain responsive to signals. The Rust core therefore exposes a way to try sending a record without waiting for buffer space, together with per-record timeout controls. These interfaces let Python and Rust account for the same timeout while allowing both layers to wait. We did 6 different candidate designs for this area of code before settling on the final approach.
3. 
Runtime errors such as handling of invalid arguments need special attention. In Java code, it is common to throw an IllegalArgumentException. The Rust equivalent is probably a panic. The problem is that there’s no way to deal with a Rust panic in a Python program. The Rust core has extra interfaces which return errors for these situations so the derived clients can handle the errors in an appropriate manner for their own languages.

All this means that we have moved a long way from a simple translation of the Java client, and into a much more subtle and complex piece of engineering.

## Final thoughts

AI cannot yet sensibly translate a complex client unattended. What it can do is accelerate the translation while engineers remain responsible for the design choices, the review process and the evidence that the result works. Getting code quickly was only the beginning; making it useful across languages was the real engineering work. The AI is amplifying the productivity of the engineers, not replacing them.

All of the code is [open-source](https://github.com/confluentinc/kafka-clients) and licensed under the Apache License 2.0 like Apache Kafka itself.
This is important because the translated code is a derivative work of an open-source project and the same permissive terms and conditions apply.

We welcome comments on the interfaces and have [RFC documents](https://github.com/confluentinc/kafka-clients/tree/master/rfc) in the GitHub repo.

Looking ahead, I expect that in mid-2027 we will start to see the continuous translation pipeline keeping all of the clients aligned with the progress in the Apache Kafka project.

## How can I try the new clients out?

We’ve just made the [first GA release of the Rust client](https://developer.confluent.io/blog/introducing-confluent-rust-client/) translated from Apache Kafka 4.4.0, only a matter of days after the release of Kafka itself.
You can read the [documentation](https://docs.confluent.io/kafka-clients/rust/current/overview.html) to get started.
It’s available on [crates.io](https://crates.io/crates/confluent-kafka) and can be installed using cargo like this:

``` bash
$ cargo add confluent-kafka
```

At the same time, we released the first preview of the new 4.4 confluent-kafka Python client.
You can read the [documentation](https://docs.confluent.io/kafka-clients/python/4.4-preview/overview.html) to get started.
There is also [API documentation](https://docs.confluent.io/kafka-clients/python/4.4-preview/api/html/index.html) for the new version.
It’s available on [PyPI](https://pypi.org/project/confluent-kafka/4.4.0b1/) and can be installed using pip like this:

``` bash
$ pip install --pre confluent-kafka
```

This is a preview, but it will turn into a new major version of the client. If you have existing code using the earlier version of the client, you will have to make some simple changes to your code when you upgrade.

*This is a project which was made possible by the advances in AI coding tools, but without the efforts and commitment of a sizable team of first-class engineers, it would not have been a success.*

*The team in no particular order is Emanuele Sabellico, Pranav Rathi, Kaushik Raina, Pranav Shah, Ojasva Jain, Shivsundar R, Ankith L, Pratyush Ranjan, Devarsh Patel, Jamie Gillenwater, Jaisen Mathai, Ramesh Balan and Matthew Seal.*
