Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Spring for Apache Kafka Milestone 1 Available

DZone's Guide to

Spring for Apache Kafka Milestone 1 Available

Spring for Apache Kafka milestone one is now available! Here's a list of what it provides, including a message listener container, annotations for POJO message listeners, and a Kafka template for async and sync Kafka topics.

· Integration Zone ·
Free Resource

SnapLogic is the leading self-service enterprise-grade integration platform. Download the 2018 GartnerMagic Quadrant for Enterprise iPaaS or play around on the platform, risk free, for 30 days.

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.

  • 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.

Original article by Gary Russell

Download A Buyer's Guide to Application and Data Integration, your one-stop-shop for research, checklists, and explanations for an application and data integration solution.

Topics:
java ,spring ,kafka ,integration

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}