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 추가
'개발자를 벗어나긴 글렀다. > Spring boot' 카테고리의 다른 글
springboot 2.1.x에서 2.3.x 버전으로 업그레이드 (0) | 2020.09.10 |
---|---|
Spring Boot + ES 연계방식 탐구 (0) | 2020.09.09 |
Spring boot + Asp 로 request / response logging (0) | 2019.01.14 |
Spring boot + WebSocket (0) | 2019.01.10 |
Spring boot + Elastic Search (0) | 2019.01.10 |