Spring for Apache Kafka Milestone 1 Available

Engineering | Gary Russell | March 14, 2016 | ...

I 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:

  • Message Listener Container.
  • Annotations for POJO message listeners (@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 Matchers 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:

  • First milestone of spring-integration-kafka (2.0) based on spring-kafka
  • A Spring Boot starter, with auto configuration support etc.
  • A new Binder implementation for spring-cloud-stream
  • Flesh out the documentation, set up a project page etc.

In the meantime, you can follow progress, report issues, etc, in the github repo.

Get the Spring newsletter

Thank you for your interest. Someone will get back to you shortly.

Get ahead

VMware offers training and certification to turbo-charge your progress.

Learn more

Get support

Tanzu Spring Runtime offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.

Learn more

Upcoming events

Check out all the upcoming events in the Spring community.

View all