트랜잭션 고급 기능

트랜잭션 고급 기능 (Transaction advanced features)

Pulsar에서 트랜잭션과 함께 쓸 수 있는 고급 기능들이 있어요. 배치 메시지를 트랜잭션으로 확인하거나, 인증을 활성화하거나, 정확히 한 번 의미를 보장하는 방법을 정리해볼게요. 기본적인 트랜잭션 사용이 익숙해졌다면 이 기능들을 하나씩 붙여보면 돼요.

출처: 문서

본문

Pulsar에서 트랜잭션과 함께 다음 고급 기능들을 사용할 수 있어요.

배치 메시지 확인 (Ack batch messages)

트랜잭션으로 배치(batch) 메시지를 확인하고 싶다면, broker.conf 또는 standalone.conf 파일에서 acknowledgmentAtBatchIndexLevelEnabledtrue로 설정해요.

acknowledgmentAtBatchIndexLevelEnabled=true

다음 예시는 컨슈머 빌더에서 트랜잭션의 배치 메시지 ack를 활성화해요.

Consumer<byte[]> consumer = pulsarClient
    .newConsumer()
    .topic(transferTopic)
    .subscriptionName("transaction-sub")
    .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
    .subscriptionType(SubscriptionType.Shared)
    .enableBatchIndexAcknowledgment(true) // enable batch index acknowledgment
    .subscribe();

인증 활성화 (Enable authentication)

트랜잭션으로 인증을 활성화하고 싶다면 아래 단계를 따라요.

  • persistent://pulsar/system/transaction_coordinator_assign 토픽에 "consume" 권한을 부여해요.
  • Pulsar 클라이언트에서 인증을 구성해요.

정확히 한 번 의미 보장 (Guarantee exactly-once semantics)

트랜잭션으로 정확히 한 번 의미를 보장하고 싶다면, 브로커, 네임스페이스, 또는 토픽 수준에서 메시지 중복 제거(deduplication)를 활성화할 수 있어요.

더 알아보기 (Learn more)