添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接



1. Config 설정

- 간단하게 설정파일 수정으로 Consumer가 설정이 끝났다.

-  application.yml

spring:
kafka:
bootstrap-servers: xxx.xxx.xxx.xxx:xxxx
consumer:
client-id: xxxx
group-id: xxxxxxxx


2. Listener

- Listener 이미 기생성된 토픽에서 데이터를 받아보자

@Slf4j
@Component
public class KafkaReceiver{

@KafkaListener(topics = "topic-name")
public void receive(String test){
log.info("@@@@@@@@@@@@@@@@@ start of kafka receive");
log.info("###### kafkaListener : {}", test);
}
}


* 발생된 에러

Case 1 :  Marking the coordinator XXXXXXX (id: XXXXXX rack: null) dead

라는 메세지를 발생하며 응답이 없음


=> Solution : Springboot 와 호환되는 Spring kafka 사용 ( https://spring.io/projects/spring-kafka )


Case 2 : Group coordinator is unavailable or invalid, will attempt rediscovery


=> Solution : hosts 파일 수정하여 kafka와 관련된 ip / hostname 추가



참조 : https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-messaging.html#boot-features-kafka