通过这个网站,我创建了Kafka Producer和Kafka Consumer
https://www.tutorialkart.com/apache-kafka/kafka-console-producer-and-consumer-example/
但是我的消费者没有从生产者那里获得任何价值,因此我决定通过Spring-boot接受,但是同一情况下,消费者没有从生产者那里获得价值。
我在StackOverFlow中浏览了几篇文章,但没有一个解决我的问题。
这是我在Spring中的代码。
Application.java
@Bean
public ConcurrentKafkaListenerContainerFactory<?, ?> kafkaListenerContainerFactory(
ConcurrentKafkaListenerContainerFactoryConfigurer configurer,
ConsumerFactory<Object, Object> kafkaConsumerFactory,
KafkaTemplate<Object, Object> template) {
ConcurrentKafkaListenerContainerFactory<Object, Object> factory = new ConcurrentKafkaListenerContainerFactory<>();
configurer.configure(factory, kafkaConsumerFactory);
factory.setErrorHandler(new SeekToCurrentErrorHandler(
new DeadLetterPublishingRecoverer(template), 3)); // dead-letter after 3 tries
return factory;
}
和Consumer.java
@KafkaListener(id = "com.stellapps.rtcreset.kafka.consumer", topics = "${rawEventsTopicName}") // add it in config part
public void messageListener(String in) {
System.out.println("Received from message: " + in);
rtcInterpreter.call(in,url);
}
任何人都可以帮忙吗?