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

Share, secure, distribute, control, and monetize your APIs with the platform built with performance, time-to-value, and growth in mind. Free 90-day trial of 3Scale by Red Hat

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

Explore the core elements of owning an API strategy and best practices for effective API programs. Download the API Owner's Manual, brought to you by 3Scale by Red Hat

Topics:
java ,spring ,kafka ,integration

Published at DZone with permission of Gary Russell, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}