Package org.apache.pulsar.io.kafka
Class KafkaBytesSource
- java.lang.Object
-
- org.apache.pulsar.io.core.PushSource<V>
-
- org.apache.pulsar.io.kafka.KafkaAbstractSource<java.nio.ByteBuffer>
-
- org.apache.pulsar.io.kafka.KafkaBytesSource
-
- All Implemented Interfaces:
java.lang.AutoCloseable,org.apache.pulsar.io.core.Source<java.nio.ByteBuffer>
public class KafkaBytesSource extends KafkaAbstractSource<java.nio.ByteBuffer>
Kafka Source that transfers the data from Kafka to Pulsar and sets the Schema type properly. We use the key and the value deserializer in order to decide the type of Schema to be set on the topic on Pulsar. In case of KafkaAvroDeserializer we use the Schema Registry to download the schema and apply it to the topic. Please refer togetSchemaFromDeserializerAndAdaptConfiguration(String, Properties, boolean)for the list of supported Deserializers. If you set StringDeserializer for the key then we use the raw key as key for the Pulsar message. If you set another Deserializer for the key we use the KeyValue schema type in Pulsar with the SEPARATED encoding. This way the Key is stored in the Pulsar key, encoded as base64 string and with a Schema, the Value of the message is stored in the Pulsar value with a Schema. This way there is a one-to-one mapping between Kafka key/value pair and the Pulsar data model.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKafkaBytesSource.ExtractKafkaAvroSchemaDeserializer-
Nested classes/interfaces inherited from class org.apache.pulsar.io.kafka.KafkaAbstractSource
KafkaAbstractSource.KafkaRecord<V>, KafkaAbstractSource.KeyValueKafkaRecord<V>
-
-
Constructor Summary
Constructors Constructor Description KafkaBytesSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.PropertiesbeforeCreateConsumer(java.util.Properties props)KafkaAbstractSource.KafkaRecordbuildRecord(org.apache.kafka.clients.consumer.ConsumerRecord<java.lang.Object,java.lang.Object> consumerRecord)-
Methods inherited from class org.apache.pulsar.io.kafka.KafkaAbstractSource
close, open, start
-
-
-
-
Method Detail
-
beforeCreateConsumer
protected java.util.Properties beforeCreateConsumer(java.util.Properties props)
- Overrides:
beforeCreateConsumerin classKafkaAbstractSource<java.nio.ByteBuffer>
-
buildRecord
public KafkaAbstractSource.KafkaRecord buildRecord(org.apache.kafka.clients.consumer.ConsumerRecord<java.lang.Object,java.lang.Object> consumerRecord)
- Specified by:
buildRecordin classKafkaAbstractSource<java.nio.ByteBuffer>
-
-