GH-2508: Upgrade Samples to 3.0.x
Resolves https://github.com/spring-projects/spring-kafka/issues/2508
This commit is contained in:
committed by
Artem Bilan
parent
23bfc785fd
commit
016e9b44c5
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>kafka-sample-03</artifactId>
|
||||
<version>2.6.5</version>
|
||||
<version>3.0.2-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>kafka-sample-03</name>
|
||||
@@ -14,14 +14,14 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<version>3.0.1-SNAPSHOT</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.support.converter.BatchMessagingMessageConverter;
|
||||
import org.springframework.kafka.support.converter.JsonMessageConverter;
|
||||
import org.springframework.kafka.support.converter.RecordMessageConverter;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.common.Foo2;
|
||||
|
||||
@@ -48,9 +49,7 @@ import com.common.Foo2;
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(Application.class);
|
||||
|
||||
private final static CountDownLatch LATCH = new CountDownLatch(1);
|
||||
final static CountDownLatch LATCH = new CountDownLatch(1);
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
|
||||
@@ -69,6 +68,23 @@ public class Application {
|
||||
return new BatchMessagingMessageConverter(converter());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NewTopic topic2() {
|
||||
return TopicBuilder.name("topic2").partitions(1).replicas(1).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NewTopic topic3() {
|
||||
return TopicBuilder.name("topic3").partitions(1).replicas(1).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
class Listener {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Listener.class);
|
||||
|
||||
@Autowired
|
||||
private KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
@@ -83,17 +99,7 @@ public class Application {
|
||||
@KafkaListener(id = "fooGroup3", topics = "topic3")
|
||||
public void listen2(List<String> in) {
|
||||
LOGGER.info("Received: " + in);
|
||||
LATCH.countDown();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NewTopic topic2() {
|
||||
return TopicBuilder.name("topic2").partitions(1).replicas(1).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public NewTopic topic3() {
|
||||
return TopicBuilder.name("topic3").partitions(1).replicas(1).build();
|
||||
Application.LATCH.countDown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user