Skip to content

Commit 0feba30

Browse files
garyrussellartembilan
authored andcommitted
Upgrade samples
1 parent abdc1e1 commit 0feba30

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

samples/sample-01/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.example</groupId>
77
<artifactId>kafka-sample-01</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
8+
<version>2.3.1.BUILD-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<name>kafka-sample-01</name>
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>2.1.0.RELEASE</version>
17+
<version>2.2.0.BUILD-SNAPSHOT</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

samples/sample-01/src/main/java/com/example/Application.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.kafka.listener.SeekToCurrentErrorHandler;
3333
import org.springframework.kafka.support.converter.RecordMessageConverter;
3434
import org.springframework.kafka.support.converter.StringJsonMessageConverter;
35+
import org.springframework.util.backoff.FixedBackOff;
3536

3637
import com.common.Foo2;
3738

@@ -58,7 +59,7 @@ public static void main(String[] args) {
5859
ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
5960
configurer.configure(factory, kafkaConsumerFactory);
6061
factory.setErrorHandler(new SeekToCurrentErrorHandler(
61-
new DeadLetterPublishingRecoverer(template), 3)); // dead-letter after 3 tries
62+
new DeadLetterPublishingRecoverer(template), new FixedBackOff(0L, 2))); // dead-letter after 3 tries
6263
return factory;
6364
}
6465

samples/sample-02/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.example</groupId>
77
<artifactId>kafka-sample-02</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
8+
<version>2.3.1.BUILD-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<name>kafka-sample-02</name>
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>2.1.0.RELEASE</version>
17+
<version>2.2.0.BUILD-SNAPSHOT</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

samples/sample-02/src/main/java/com/example/Application.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.springframework.kafka.support.converter.Jackson2JavaTypeMapper.TypePrecedence;
3535
import org.springframework.kafka.support.converter.RecordMessageConverter;
3636
import org.springframework.kafka.support.converter.StringJsonMessageConverter;
37+
import org.springframework.util.backoff.FixedBackOff;
3738

3839
import com.common.Bar2;
3940
import com.common.Foo2;
@@ -53,7 +54,7 @@ public static void main(String[] args) {
5354
ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
5455
configurer.configure(factory, kafkaConsumerFactory);
5556
factory.setErrorHandler(new SeekToCurrentErrorHandler(
56-
new DeadLetterPublishingRecoverer(template), 3));
57+
new DeadLetterPublishingRecoverer(template), new FixedBackOff(0L, 2)));
5758
return factory;
5859
}
5960

samples/sample-03/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.example</groupId>
77
<artifactId>kafka-sample-03</artifactId>
8-
<version>0.0.1-SNAPSHOT</version>
8+
<version>2.3.1.BUILD-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<name>kafka-sample-03</name>
@@ -14,7 +14,7 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>2.1.0.RELEASE</version>
17+
<version>2.2.0.BUILD-SNAPSHOT</version>
1818
<relativePath/> <!-- lookup parent from repository -->
1919
</parent>
2020

samples/sample-03/src/main/java/com/example/Application.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.springframework.context.annotation.Bean;
3131
import org.springframework.kafka.annotation.KafkaListener;
3232
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
33+
import org.springframework.kafka.config.TopicBuilder;
3334
import org.springframework.kafka.core.ConsumerFactory;
3435
import org.springframework.kafka.core.KafkaTemplate;
3536
import org.springframework.kafka.support.converter.BatchMessagingMessageConverter;
@@ -56,9 +57,10 @@ public static void main(String[] args) {
5657
@Bean
5758
public ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
5859
ConcurrentKafkaListenerContainerFactoryConfigurer configurer,
59-
ConsumerFactory<Object, Object> kafkaConsumerFactory,
60-
KafkaTemplate<Object, Object> template) {
61-
ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
60+
ConsumerFactory<Object, Object> kafkaConsumerFactory) {
61+
62+
ConcurrentKafkaListenerContainerFactory<Object, Object> factory =
63+
new ConcurrentKafkaListenerContainerFactory<>();
6264
configurer.configure(factory, kafkaConsumerFactory);
6365
factory.setBatchListener(true);
6466
factory.setMessageConverter(batchConverter());
@@ -92,8 +94,13 @@ public void listen2(List<String> in) {
9294
}
9395

9496
@Bean
95-
public NewTopic topic() {
96-
return new NewTopic("topic2", 1, (short) 1);
97+
public NewTopic topic2() {
98+
return TopicBuilder.name("topic2").partitions(1).replicas(1).build();
99+
}
100+
101+
@Bean
102+
public NewTopic topic3() {
103+
return TopicBuilder.name("topic3").partitions(1).replicas(1).build();
97104
}
98105

99106
}

0 commit comments

Comments
 (0)