본문 바로가기

MSA

33. micro service에 Kafka 적용 #1 (consumer)

1. dependency 추가

3.0.0은 다음과 같은 오류로 downgrade Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.autoconfigure.kafka.ConcurrentKafkaListenerContainerFactoryConfigurer and org.springframework.kafka.listener.ConsumerProperties Process finished with exit code 0
consumer serice(product-ms)

2. KafkaConsumerConfig class

consumer는 key & value를 StringDeserializer(언마샬링)

3. KafkaConsumer class

해당토픽의 prodId가 있다면 조회해서 토픽에 있는 수량만큼 차감하여 저장