2025/05/06 5

[Spring for Apache Kafka] 4. Application Events

1. 이벤트Spring Kafka는 여러 소비자 관련 이벤트를 발행함카테고리이벤트명설명주요 속성소비자 생애주기ConsumerStartingEvent소비자 스레드가 생성될 때 발생(poll 시작 전)container, sourceConsumerStartedEvent소비자가 실제로 폴링을 시작하려고 할 때 발생container, sourceConsumerFailedToStartEvent소비자가 시작되지 못한 경우 발생(consumerStartTimeout 초과)container, sourceConsumerStoppingEvent소비자가 정지 직전에 발생container, partitionsConsumerStoppedEvent소비자가 정지된 후 발생container, source, reasonConsumerR..

카테고리 없음 2025.05.06

[Spring for Apache Kafka] 3. Receiving Messages: Message Listener

이 문서는 해당 섹션의 일부분만 정리되었음. 1. Message ListenersKafka에서 메시지를 처리하려면 리스너를 제공해야 함인터페이스설명MessageListener개별 메시지 처리AcknowledgingMessageListener메시지 처리 후 수동으로 오프셋을 커밋ConsumerAwareMessageListener메시지 처리 시 Consumer 객체 접근BatchMessageListener배치 메시지 처리BatchAcknowledgingMessageListener배치 메시지 처리 후 수동 커밋 예제더보기MessageListener@KafkaListener(topics = "topic1")public void onMessage(ConsumerRecord record) { System.ou..

카테고리 없음 2025.05.06

[Spring for Apache Kafka] 2. Sending Messages

1. DefaultKafkaProducerFactory기본적으로 모든 클라이언트에서 공유하는 단일 Kafka 프로듀서를 생성 설정) DefaultKafkaProducerFactory더보기@Configurationpublic class KafkaProducerConfig { @Bean public DefaultKafkaProducerFactory producerFactory() { Map configs = new HashMap(); configs.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); configs.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONF..

카테고리 없음 2025.05.06

[Spring for Apache Kafka] 1. Basic

1. Connecting to Kafka구성 요소역할ProducerFactory메시지 전송을 위한 팩토리 생성ConsumerFactory메시지 수신을 위한 팩토리 생성 Factory ListenerFactory의 Listener는 프로듀서/컨슈머가 만들어지거나 닫힐 때 호출하는 메서드를 정의한 인터페이스입니다.생성된 프로듀서/컨슈머의 bean id는 factory의 beanName + kafka client id 패턴으로 정의됩니다. 예제더보기더보기public class MyProducerFactoryListener implements ProducerFactory.Listener { @Override public void producerAdded(String id, Producer produc..

카테고리 없음 2025.05.06

[실전 카프카 개발부터 운영까지] 4. 카프카의 내부 동작 원리와 구현

고승범 님의 "실전 카프카 개발부터 운영까지" 책을 정리한 포스팅 입니다.1. 카프카 리플리케이션동작더보기토픽 생성/opt/bitnami/kafka/bin/kafka-topics.sh --create --topic topic_chat \--bootstrap-server localhost:9092 \--replication-factor 2 \--partitions 2 토픽 조회 /opt/bitnami/kafka/bin/kafka-topics.sh --topic topic_chat --describe \ --bootstrap-server localhost:9092 토픽 메시지 생성/opt/bitnami/kafka/bin/kafka-console-producer.sh --topic topic_chat \ --..

카테고리 없음 2025.05.06