클라이언트 사용 준비
클라이언트 사용 준비 (Clients)
클라이언트 라이브러리를 설정하고 클라이언트 객체를 만든 뒤에는, 클라이언트로 할 수 있는 추가 작업을 살펴볼 수 있어요. 여러 어드버타이즈드 리스너(advertised listeners)를 써서 내부·외부 네트워크를 모두 연결하거나, 클라이언트 메모리 사용량을 제한하는 방법을 정리해볼게요.
출처: 문서
본문
클라이언트 라이브러리를 설정하고 클라이언트 객체를 만든 뒤에는, 클라이언트 작업을 시작하기 위해 더 살펴볼 수 있어요.
여러 어드버타이즈드 리스너로 클라이언트 만들기 (Create a client with multiple advertised listeners)
내부 네트워크와 외부 네트워크의 클라이언트가 모두 Pulsar 클러스터에 연결할 수 있도록, Pulsar는 advertisedListeners를 도입했어요.
다음 예시는 여러 어드버타이즈드 리스너를 사용해 Python 클라이언트를 만드는 모습이에요.
PulsarClient client = PulsarClient.builder()
.serviceUrl("pulsar://xxxx:6650")
.listenerName("external")
.build();
ClientConfiguration clientConfiguration;
clientConfiguration.setListenerName("external");
Client client("pulsar://xxxx:6650", clientConfiguration);
import pulsar
client = pulsar.Client('pulsar://localhost:6650', listener_name='external')
메모리 제한 설정 (Set memory limits)
메모리 제한(memory limits) 파라미터로 클라이언트 전체 메모리 사용량을 제어할 수 있어요. 이 클라이언트 아래의 프로듀서와 컨슈머는 할당된 메모리를 두고 경쟁하게 돼요. 구현 상세는 PIP 74: Pulsar client memory limits를 참고하세요.
PulsarClient client = PulsarClient.builder().serviceUrl("pulsar://xxxx:6650").memoryLimit(64, SizeUnit.MEGA_BYTES).build();
client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: "pulsar://xxxx:6650",
MemoryLimitBytes: 64 * 1024 * 1024, // Unit: byte
})
더 알아보기 (Learn more)
- 클라이언트 라이브러리 — Pulsar가 제공하는 클라이언트 라이브러리 전체 목록을 살펴봐요.
- Java 클라이언트 — Java 클라이언트 문서를 확인해요.
- Python 클라이언트 — Python 클라이언트 문서를 확인해요.
- C++ 클라이언트 — C++ 클라이언트 문서를 확인해요.
- Go 클라이언트 — Go 클라이언트 문서를 확인해요.