Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To connect an Apache Camel application to Apache Kafka, use Camel’s Kafka component in a route that consumes from or produces to a Kafka topic. Choose a different tool when the main job is managed data movement: Camel Kafka Connector adapts Camel components for Kafka Connect. If the application’s core job is processing Kafka streams with a stream-processing API, consider Kafka Streams instead. These options operate at different architectural layers.

Choose the right Kafka integration

Start with who should own the work: a Camel route in your application, a Kafka Connect worker, or a Kafka Streams application. The need for routing, data movement, or stream processing helps distinguish them.

Option Best fit How it works
Direct Camel Kafka route Your application needs to produce to or consume from Kafka and apply Camel routing or mediation. A Camel route uses the Kafka component’s endpoint to read from or write to a topic. [Apache Camel Kafka component documentation]
Camel Kafka Connector You need connector-style movement between Kafka and another system, and an appropriate Camel component is available. It adapts Camel components for Kafka Connect. A source connector imports data into Kafka; a sink connector exports data from Kafka. [Camel Kafka Connector user guide]
Kafka Streams Your application’s primary responsibility is processing Kafka streams using the Kafka Streams API. Kafka Streams is a separate processing library. Its processing tasks are derived from topic partitions, which provide the basis for parallel processing. [Kafka Streams documentation]

Kafka Connect is a framework for moving data between Kafka and other systems. Its documented capabilities include standalone and distributed operation, REST-based connector management, automatic offset management, and bridging streaming and batch systems. [Kafka Connect documentation]

How a direct Camel route connects to Kafka

Camel routes are defined with a routing DSL or XML. A CamelContext contains components, and components provide endpoints that routes use to consume or send messages. The Kafka component endpoint follows the form kafka:topic[?options]. [Apache Camel architecture documentation] [Apache Camel Kafka component documentation]

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Consume messages from a topic

A minimal consumer endpoint can start a route like this:

from("kafka:test?brokers=localhost:9092")
    .log("Received ${body}");

The component documentation’s example uses the topic test and broker localhost:9092. A route can inspect message content and Kafka metadata exposed as Camel exchange headers, including topic, partition, offset, and key. [Apache Camel Kafka component documentation]

Produce messages to a topic

A producer route can set the message body and the CamelKafkaKey header before sending to a Kafka endpoint:

from("direct:publish")
    .setHeader("CamelKafkaKey", constant("order-123"))
    .setBody(constant("order created"))
    .to("kafka:orders?brokers=localhost:9092");

This illustrates the route shape, not a production-ready configuration. Confirm endpoint options and supported header types against the Camel version in use. Outgoing Kafka header values must be serializable to supported byte-compatible values. [Apache Camel Kafka component documentation]

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What to configure before production

The simple examples omit the choices that determine how a deployed application connects, handles failures, and manages message delivery. Align these settings with the Kafka broker, runtime, Camel release, and application requirements.

  • Connection and security: configure the actual broker addresses and the required authentication and TLS settings.
  • Serialization: select formats and serializers compatible with both producers and consumers, and ensure any Kafka headers sent from Camel use supported byte-compatible values.
  • Offsets and commits: decide when consumer offsets are committed and what recovery behavior the application needs. Camel documents controls for commit behavior.
  • Error handling: define how the route handles consumer errors, retries, and messages that cannot be processed; plan a retry or dead-letter strategy where appropriate.
  • Delivery semantics: assess idempotency and the behavior of the complete producer, broker, consumer, and processing pipeline. An exactly-once-related option by itself does not establish end-to-end exactly-once behavior.

These controls and their exact configuration are version-sensitive. The Camel 4.18 component reference is useful for that release, but applications should use documentation matching their actual Camel and Kafka versions. The connector and Kafka Connect guides cited above also include versioned material; verify current compatibility and deployment support before choosing a topology.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Decide who should operate the integration

For a direct route, the application owns Camel routing and its Kafka interaction. With Camel Kafka Connector, Kafka Connect workers manage connector-style data movement; Connect supports standalone or distributed operation and REST-based connector management. Kafka Streams puts stream processing in the application using its own API, with topic partitions underpinning processing parallelism. Select the model that matches operational ownership as well as data flow; they are not interchangeable names for the same feature.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.