All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mageddo.tobby.producer.kafka.JdbcKafkaProducer Maven / Gradle / Ivy

There is a newer version: 2.1.6-alpha
Show newest version
package com.mageddo.tobby.producer.kafka;

import com.mageddo.tobby.producer.Producer;
import com.mageddo.tobby.producer.kafka.converter.ProducedRecordConverter;
import com.mageddo.tobby.producer.kafka.converter.ProducerRecordConverter;

import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.serialization.Serializer;

public class JdbcKafkaProducer {

  private final Producer delegate;
  private final Serializer keySerializer;
  private final Serializer valueSerializer;

  public JdbcKafkaProducer(Producer delegate, Serializer keySerializer, Serializer valueSerializer) {
    this.delegate = delegate;
    this.keySerializer = keySerializer;
    this.valueSerializer = valueSerializer;
  }

  public RecordMetadata send(ProducerRecord record) {
    return ProducedRecordConverter.toMetadata(this.delegate.send(
        ProducerRecordConverter.of(
            this.keySerializer, this.valueSerializer, record
        )
    ));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy