Java Kafka Library 차이?? (Spring kafka vs apache kafka)

고뱅쟁이·2020년 6월 2일
0
post-thumbnail

궁금증

java spring boot 를 이용하여 kafka Producer와 consumer를 만들 일이 생겼다.
시작은 당연히 Hello World!를 찍는것부터 해야되지 않는가!
그래서 예제를 찾아보다보니 어디는 apache kafka를 추가하고 어디는 spring kafka를 추가하는 것이었다.
뭐지... 둘의 차이는 뭐지...라고 궁금증이 시작되었다.

찾아보기

구글에 물어봐도 뭔가 명확한 느낌이 들지 않았다.
이것저것 검색어를 바꿔봐도..ㅠㅠ
다시 처음으로 돌아와 spring for apache kafka를 검색해봤더니

역시 답은 레퍼런스 문서에!

(사실은 옆에있는 개요문서)

https://spring.io/projects/spring-kafka

요로코롬 설명이 나와있던 것이었다.

The Spring for Apache Kafka (spring-kafka) project applies core Spring concepts to the development of Kafka-based messaging solutions. It provides a "template" as a high-level abstraction for sending messages. It also provides support for Message-driven POJOs with @KafkaListener annotations and a "listener container". These libraries promote the use of dependency injection and declarative. In all of these cases, you will see similarities to the JMS support in the Spring Framework and RabbitMQ support in Spring AMQP.

spring boot에서 apache kafka를 조금 더 편리하게 사용할 수 있도록 한 라이브러리가 spring kafka이다.(이러니 검색해도 잘안나오지...)
spring kafka를 사용하면 apache kafka 라이브러리도 같이 사용할 수 있다.
그래서 나는 그냥 spring boot에서 kafka를 사용할 때 spring kafka 라이브러리를 추가하기로 했다.

Maven 사용 시

<dependency>
  <groupId>org.springframework.kafka</groupId>
  <artifactId>spring-kafka</artifactId>
</dependency>

gradle 사용 시

compile 'org.springframework.kafka:spring-kafka'

아래에는 호환성에 대한 설명이 나온 표이다. 내가 사용하는 스프링부트 버전과 맞는 버전을 사용하기 위해서 참고하면 될 것 같다.

결론

  1. spring kafka는 apache kafka의 상위호환이다.
  2. 문서를 꼼꼼히 읽자..
  3. 어쨌든 궁금한건 해결!
  4. 뭔차이가 있어! 하고 들어오신 분들께는 괜한 어그로를 끌었다.
profile
냥이들과 함께하는 만년 초보 개발자

1개의 댓글

comment-user-thumbnail
2020년 6월 4일

스프링에선 스프링 카프카 쓰면되겠네요
도움되었습니다. 감사합니다.

답글 달기