Get ahead
VMware offers training and certification to turbo-charge your progress.
Learn moreI am pleased to announce that the spring-kafka
(Spring for Apache Kafka) first milestone is now available (1.0.0.M1
).
The existing spring-integration-kafka
extension project - currently at version 1.3.0.RELEASE
supports Kafka 0.8.x.x and is used in Spring XD (Kafka MessageBus
) and Spring Cloud Stream (Kafka Binder
).
This new project (spring-kafka
) breaks out the core components into a separate project. It is based on the new 0.9.0.x pure Java Kafka clients.
spring-kafka
brings the familiar Spring programming model to Apache Kafka for any Spring user, not just those using Spring Integration. An upcoming spring-integration-kafka
release will be a complete rewrite, utilizing the spring-kafka
project internally.
Much like the other messaging projects in the Spring portfolio, spring-kafka
provides:
@KafkaListener
- similar to @JmsListener
and @RabbitListener
).KafkaTemplate
for sync and async sending to Kafka topics:@Configuration
@EnableKafka
public class KafkaConfig {
// Infrastructure @Beans omitted.
// See Reference Manual and tests for comprehensive sample
@Bean
public Listener listener() {
return new Listener();
}
}
public class Listener {
@KafkaListener(topics = "myTopic")
public void handleFromKakfa(String payload) {
...
}
}
Using maven or gradle:
<dependencies>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>1.0.0.M1</version>
</dependency>
</dependencies>
dependencies {
compile 'org.springframework.kafka:spring-kafka:1.0.0.M1'
}
In addition, the spring-kafka-test
artifact is available, containing support for testing, including an embedded Kafka broker, hamcrest Matcher
s etc.
Both artifacts are available in the repo.spring.io/milestone
repository.
See the milestone 1 reference manual for more information.
Many thanks to Soby Chacko (for kicking off the initial Spring Integration Kafka extension), Marius Bogoevici and Artem Bilan for their help with this important project.
#Next Steps:
spring-integration-kafka
(2.0
) based on spring-kafka
Binder
implementation for spring-cloud-stream
In the meantime, you can follow progress, report issues, etc, in the github repo.