관련 블로그 글 | |
이벤트 기반 아키텍처 도입편 with RabbitMQ | https://jm-baek.tistory.com/358 |
분산 트랜잭션 with RabbitMQ | https://jm-baek.tistory.com/364 |
분산 메세지 큐 1편 - 읽은 책 | https://jm-baek.tistory.com/325 |
분산 메세지 큐 2편 - 읽은 책 | https://jm-baek.tistory.com/330 |
Monolithic Architecture(MA)
Event Driven Architecture(EDA)
해당 아키텍처를 메세지 기반 아키텍처라고도 부르지만 일반적으로 게시구독(Pub/Sub) 모델 이라고 부른다.
이벤트를 생성하고 소비하는 것에 대해서만 알면 되기 때문에 분리한다.
이벤트 기반 장점
- Decoupling
- Dependecy Inversion
- Scalability
Why Message Queue?
바라는 점
- 메시지 보존: RabbitMQ는 소비자가 메시지를 수신하지 못하더라도 메시지를 큐에 보관하여 나중에 소비자가 준비되면 처리할 수 있게 합니다.
- 메세지를 송수신 했는지 알기 위해서는 체크해주는 역할이 필요하다.
중요한 점
- 메세지 처리 로직을 어떻게 구현하는지가 중요한 부분 같음.
- 최소 한 번 보내기, 최대 한 번 보내기
느낀점
구현은 어떻게 하겠지만 세부 로직 처리 등.. 쉽지 않다..
메세지 큐로 클라이언트에게 데이터를 전달할 수없다.
따로 다른 기술을 도입해야한다. 그것이 SseEmitter이다.
Message
RabbitMQ vs Kafaka
RabbitMQ
라운드 로빈 방식 이해
라운드 로빈 방식에서는 각 메시지가 한 번에 한 소비자에게만 할당됩니다. 예를 들어, 큐에 메시지가 A, B, C 순서로 들어가고, 두 소비자가 큐를 구독하고 있다면, RabbitMQ는 메시지 A를 소비자 1에게, 메시지 B를 소비자 2에게, 메시지 C를 다시 소비자 1에게 전달합니다. 이렇게 각 소비자가 순차적으로 메시지를 받게 되며, 동일한 메시지를 모든 소비자가 받지는 않습니다.
모든 소비자가 동일한 메시지를 받게 하려면?
- 별도의 큐로 메시지 복제
각각의 소비자가 동일한 메시지를 받게 하려면, 각 소비자마다 개별 큐를 만들어 메시지를 복제하거나 팬아웃(Fanout) 방식의 Exchange를 사용하여 여러 큐에 동일한 메시지를 브로드캐스트할 수 있습니다. - 팬아웃(Fanout) Exchange 사용
팬아웃 Exchange는 메시지를 수신하는 모든 큐에 메시지를 전송할 수 있는 방식입니다. 따라서 여러 소비자가 동일한 메시지를 받아야 하는 경우 팬아웃 Exchange를 사용하고 각 소비자에 대해 별도의 큐를 바인딩하는 방법이 일반적입니다.
There are a few exchange types available: direct, topic, headers and fanout.
- A producer is a user application that sends messages.
- A queue is a buffer that stores messages.
- A consumer is a user application that receives messages.
Message Convert
1) SimpleMessageConverter
2) SerializerMessageConverter
3) Jackson2JsonMessageConverter
4) MarshallingMessageConverter
5) Jackson2XmlMessageConverter
6) ContentTypeDelegatingMessageConverter
Example Code
참고 사이트
RabbitMQ와 Kafka - 메시지 대기열 시스템 간의 차이점 - AWS
RabbitMQ는 간단한 아키텍처로 복잡한 메시지 라우팅을 제공하는 반면, Kafka는 애플리케이션이 스트림 기록의 데이터를 처리할 수 있을 만큼 내구성이 우수한 메시지 브로커 시스템을 제공합니다.
aws.amazon.com
Message Converters :: Spring AMQP
Yet another option is the MarshallingMessageConverter. It delegates to the Spring OXM library’s implementations of the Marshaller and Unmarshaller strategy interfaces. You can read more about that library here. In terms of configuration, it is most commo
docs.spring.io
Getting Started | Messaging with RabbitMQ
To run the code without Spring Boot Docker Compose support, you need a version of RabbitMQ running locally to connect to. To do this, you can use Docker Compose, but you must first make two changes to the compose.yaml file. First, modify the ports entry in
spring.io
'회사 업무 > 기술 연구편' 카테고리의 다른 글
[Document] springdoc-openapi (0) | 2025.02.26 |
---|---|
[Document] API 명세서 툴 비교 (0) | 2025.02.21 |
[Security] 접근 제어 정책(Access Control) (0) | 2025.02.13 |
자바 엔터프라이즈 플랫폼 (0) | 2024.12.05 |
분산 트랜잭션 연구편 with RabbitMQ (0) | 2024.11.14 |