-theGroup='de.example.spring.kafka'
-theName='spring-kafka-example'
-theVersion='1.0-SNAPSHOT'
+theGroup=de.example.spring.kafka
+theName=spring-kafka-example
+theVersion=1.0-SNAPSHOT
@Bean
CommandLineRunner lookup(Sender sender) {
return args -> {
- String topic = "example.topic";
+ String topic = "test";
String message = "example message";
import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.core.ProducerFactory;
import java.util.HashMap;
import java.util.Map;
+@Configuration
public class SenderConfig {
@Value("${kafka.bootstrap.servers}")
logging:
level:
org:
- springframework:
- ws: debug
- ROOT: debug
+ springframework: info
+ ROOT: info
spring:
main:
@Bean
CommandLineRunner lookup(Receiver receiver) {
return args -> {
- String sleepTime = "60000";
-
- if (args.length > 0) {
- sleepTime = args[0];
- }
-
- Thread.sleep(Long.valueOf(sleepTime));
};
}
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;
-import java.util.concurrent.CountDownLatch;
-
public class Receiver {
private static final Logger LOGGER = LoggerFactory.getLogger(Receiver.class);
- private CountDownLatch latch = new CountDownLatch(1);
-
- @KafkaListener(topics = "example.topic")
+ @KafkaListener(topics = "test")
public void receiveMessage(String message) {
LOGGER.info("received message='{}'", message);
- latch.countDown();
}
- public CountDownLatch getLatch() {
- return latch;
- }
}
logging:
level:
org:
- springframework:
- ws: debug
- ROOT: debug
+ springframework: info
+ ROOT: info
spring:
main: