MuleESB / Apache Camel Interview Questions
How do you integrate Apache Camel with Apache Kafka?
Camel integrates with Kafka via the camel-kafka component, which wraps the native Kafka Java client. The URI scheme is kafka:topicName?brokers=...&options. It supports both consuming (from()) and producing (to()) messages, with full access to Kafka record metadata through Exchange headers.
org.apache.camel
camel-kafka
// Consumer: read from Kafka, process, produce to Kafka:
from("kafka:orders?brokers=localhost:9092&groupId=order-processor")
.log("Received from partition ${header.kafka.PARTITION} offset ${header.kafka.OFFSET}")
.unmarshal().json(Order.class)
.process(new OrderProcessor())
.marshal().json()
.to("kafka:processed-orders?brokers=localhost:9092");
// application.properties for Camel Spring Boot:
camel.component.kafka.brokers=localhost:9092
camel.component.kafka.security-protocol=SASL_SSL
camel.component.kafka.sasl-mechanism=PLAINKey consumer options: groupId (consumer group), autoOffsetReset (earliest/latest), maxPollRecords, pollTimeoutMs. Key producer options: partitionKey, compressionCodec. The component automatically sets headers: kafka.TOPIC, kafka.PARTITION, kafka.OFFSET, kafka.KEY. Use seekTo=beginning for replay. Manual offset commit is supported via allow.auto.create.topics and the KafkaManualCommit header.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
