메시지 생성 및 소비하기
메시지 생성 및 소비하기 (Produce and consume messages)
이 튜토리얼에서는 Pulsar 클라이언트를 구성하고, 구독을 만들고, 프로듀서를 생성해 테스트 메시지를 보내고 결과를 확인하는 과정을 차근차근 배워볼게요. 앞선 튜토리얼에서 만든 토픽에 실제로 메시지를 흘려보는 단계예요.
출처: 문서
본문
이 튜토리얼에서 할 일은 다음과 같아요.
- Pulsar 클라이언트 구성하기
- 구독(subscription) 생성하기
- 프로듀서(producer) 생성하기
- 테스트 메시지 보내기
- 결과 확인하기
사전 준비 (Prerequisites)
메시지 생성 및 소비 (Produce and consume messages)
메시지를 생성하고 소비하려면 다음 단계를 완료해요.
conf/client.conf파일에서webServiceUrl과brokerServiceUrl을 자신의 서비스 URL로 교체해요.apache/pulsar/test-topic에서 메시지를 소비할 구독을 생성해요.
bin/pulsar-client consume -s sub apache/pulsar/test-topic -n 0
- 새 터미널에서 프로듀서를 만들고 test-topic에 10개의 메시지를 보내요.
bin/pulsar-client produce apache/pulsar/test-topic -m "---------hello apache pulsar-------" -n 10
- 결과를 확인해요.
----- got message --------------hello apache pulsar------------ got message --------------hello apache pulsar------------ got message --------------hello apache pulsar------------ got message --------------hello apache pulsar------------ got message --------------hello apache pulsar------------ got message --------------hello apache pulsar------------ got message --------------hello apache pulsar------------ got message --------------hello apache pulsar------------ got message --------------hello apache pulsar------------ got message --------------hello apache pulsar-------Output from the producer side shows the messages have been produced successfully:18:15:15.489 [main] INFO org.apache.pulsar.client.cli.PulsarClientTool - 10 messages successfully produced.
관련 토픽 (Related Topics)
더 알아보기 (Learn more)
- 토픽 생성 방법은 토픽 생성하기 튜토리얼을 참고해요.
- 테넌트 설정은 테넌트 설정하기에서 확인해요.
- 네임스페이스 생성은 네임스페이스 생성하기를 봐요.
- 클러스터 관리 방법은 클러스터 관리 문서를 참고해요.