Skip to content

add support for multi partition kafka topics #5398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class KafkaConsumerConnector(

// Currently consumed offset, is used to calculate the topic lag.
// It is updated from one thread in "peek", no concurrent data structure is necessary
// Note: Currently, this value used for metric reporting will not be accurate if using a multi-partition topic.
private var offset: Long = 0

// Markers for metrics, initialized only once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object KafkaMessagingProvider extends MessagingProvider {

Try(AdminClient.create(commonConfig + (AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG -> config.kafkaHosts)))
.flatMap(client => {
val partitions = 1
val partitions = topicConfig.getOrElse("partitions", "1").toInt
val nt = new NewTopic(topic, partitions, kafkaConfig.replicationFactor).configs(topicConfig.asJava)

def createTopic(retries: Int = 5): Try[Unit] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class KafkaProducerConnector(
/** Sends msg to topic. This is an asynchronous operation. */
override def send(topic: String, msg: Message, retry: Int = 3): Future[ResultMetadata] = {
implicit val transid: TransactionId = msg.transid
val record = new ProducerRecord[String, String](topic, "messages", msg.serialize)
val record = new ProducerRecord[String, String](topic, msg.serialize)
val produced = Promise[ResultMetadata]()

Future {
Expand Down