You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IMPORTANT: When using Spring Boot, omit the version and Boot will automatically bring in the correct version that is compatible with your Boot version:
30
+
IMPORTANT: When using Spring Boot, (and you haven't used start.spring.io to create your project), omit the version and Boot will automatically bring in the correct version that is compatible with your Boot version:
32
31
32
+
.Maven
33
33
====
34
34
[source,xml,subs="+attributes"]
35
35
----
@@ -40,114 +40,110 @@ IMPORTANT: When using Spring Boot, omit the version and Boot will automatically
40
40
----
41
41
====
42
42
43
-
The following example shows how to do so with Gradle:
44
-
43
+
.Gradle
45
44
====
46
45
[source,groovy,subs="+attributes"]
47
46
----
48
47
compile 'org.springframework.kafka:spring-kafka'
49
48
----
50
49
====
51
50
51
+
However, the quickest way to get started is to use https://start.spring.io[start.spring.io] (or the wizards in Spring Tool Suits and Intellij IDEA) and create a project, selecting 'Spring for Apache Kafka' as a dependency.
52
52
53
53
[[compatibility]]
54
54
==== Compatibility
55
55
56
56
This quick tour works with the following versions:
57
57
58
-
* Apache Kafka Clients 2.4.1
58
+
* Apache Kafka Clients 2.6.1
59
59
* Spring Framework 5.3.x
60
60
* Minimum Java version: 8
61
61
62
-
==== A Very, Very Quick Example
62
+
==== Getting Started
63
63
64
-
As the following example shows, you can use plain Java to send and receive a message:
64
+
The simplest way to get started is to use https://start.spring.io[start.spring.io] (or the wizards in Spring Tool Suits and Intellij IDEA) and create a project, selecting 'Spring for Apache Kafka' as a dependency.
65
+
Refer to the https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-kafka[Spring Boot documentation] for more information about its opinionated auto configuration of the infrastructure beans.
65
66
67
+
Here is a minimal consumer application.
68
+
69
+
===== Spring Boot Consumer App
70
+
71
+
.Application
66
72
====
67
-
[source,java]
73
+
[source,java]
68
74
----
69
-
@Test
70
-
public void testAutoCommit() throws Exception {
71
-
logger.info("Start auto");
72
-
ContainerProperties containerProps = new ContainerProperties("topic1", "topic2");
73
-
final CountDownLatch latch = new CountDownLatch(4);
IMPORTANT: Spring for Apache Kafka is designed to be used in a Spring Application Context.
144
+
For example, if you create the listener container yourself outside of a Spring context, not all functions will work unless you satisfy all of the `...Aware` interfaces that the container implements.
148
145
149
-
You can do the same work as appears in the previous example with Spring configuration in Java.
150
-
The following example shows how to do so:
146
+
Here is an example of an application that does not use Spring Boot.
151
147
152
148
====
153
149
[source,java]
@@ -180,13 +176,15 @@ public class Config {
180
176
181
177
@Bean
182
178
public ConsumerFactory<Integer, String> consumerFactory() {
183
-
return new DefaultKafkaConsumerFactory<>(consumerConfigs());
179
+
return new DefaultKafkaConsumerFactory<>(consumerProps());
0 commit comments