barsPartition assignment

Route Kafka records to specific partition.

circle-exclamation

K2K offers two ways to map source cluster topics to destination partitions:

  1. Preserve Source Cluster Partition: Use the same partition as the source topic.

  2. Kafka Producer-Based Routing: Use a producer configured routing strategy. Useful e.g when the target topic's partitions differ from the source to accommodate varying partition structures.

This guide covers these options to optimize your mapping strategy.

This tutorial assumes the following files exist (See Setting up for more details):

name: "my-first-replication"
features:
  autoCreateControlTopics: enabled
  autoCreateTopics: enabled
source:
  kafka:
    common:
      "bootstrap.servers": "kafka-source:9092"
    consumer:
      "group.id": "k2k.my-first-k2k"
target:
  kafka:
    common:
      "bootstrap.servers": "kafka-target:9092"
replication:
  - source:
      topic: ".*"
  - sink:
      topic: source
      partition: source

To ensure a clean start, execute this command to reset any prior configurations from earlier tutorials.

Preserving the original topic partition

To retain the original record partition during copying, set the sink partition property to "source".

chevron-rightk2k-pipeline.ymlhashtag
chevron-rightSee it in actionhashtag

Producer defined partition

Another option is to write records using the producer's default partitioning strategy. If chosen, the Kafka Producer determines the target partition based on its configured partition assignment strategy.

circle-exclamation
chevron-rightk2k-pipeline.ymlhashtag
chevron-rightSee it in actionhashtag

Was this helpful?