@ParametersAreNonnullByDefault public final class KafkaMessageFactory extends Object
MessageReader
and MessageWriter for Kafka Producer and Consumer.
These can be used as an alternative to CloudEventDeserializer and CloudEventSerializer to
manually serialize/deserialize CloudEvent messages.
| Modifier and Type | Method and Description |
|---|---|
static <K> MessageReader |
createReader(org.apache.kafka.clients.consumer.ConsumerRecord<K,byte[]> record)
Create a
MessageReader to read ConsumerRecord. |
static MessageReader |
createReader(org.apache.kafka.common.header.Headers headers,
byte[] payload) |
static MessageWriter<io.cloudevents.rw.CloudEventWriter<org.apache.kafka.clients.producer.ProducerRecord<Void,byte[]>>,org.apache.kafka.clients.producer.ProducerRecord<Void,byte[]>> |
createWriter(String topic) |
static <K> MessageWriter<io.cloudevents.rw.CloudEventWriter<org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>>,org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>> |
createWriter(String topic,
Integer partition,
K key) |
static <K> MessageWriter<io.cloudevents.rw.CloudEventWriter<org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>>,org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>> |
createWriter(String topic,
Integer partition,
Long timestamp,
K key)
Create a
MessageWriter to write a ProducerRecord. |
static <K> MessageWriter<io.cloudevents.rw.CloudEventWriter<org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>>,org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>> |
createWriter(String topic,
K key) |
public static <K> MessageReader createReader(org.apache.kafka.clients.consumer.ConsumerRecord<K,byte[]> record) throws io.cloudevents.rw.CloudEventRWException
MessageReader to read ConsumerRecord.K - the type of the record keyrecord - the record to convert to MessageReaderMessageReaderio.cloudevents.rw.CloudEventRWException - if something goes wrong while resolving the SpecVersion or if the message has unknown encodingpublic static MessageReader createReader(org.apache.kafka.common.header.Headers headers, byte[] payload) throws io.cloudevents.rw.CloudEventRWException
io.cloudevents.rw.CloudEventRWExceptioncreateReader(ConsumerRecord)public static <K> MessageWriter<io.cloudevents.rw.CloudEventWriter<org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>>,org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>> createWriter(String topic, Integer partition, Long timestamp, K key)
MessageWriter to write a ProducerRecord.K - the key typetopic - the topic where to write the recordpartition - the partition where to write the recordtimestamp - the timestamp of the recordkey - the key of the recordMessageWriterpublic static <K> MessageWriter<io.cloudevents.rw.CloudEventWriter<org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>>,org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>> createWriter(String topic, Integer partition, K key)
public static <K> MessageWriter<io.cloudevents.rw.CloudEventWriter<org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>>,org.apache.kafka.clients.producer.ProducerRecord<K,byte[]>> createWriter(String topic, K key)
public static MessageWriter<io.cloudevents.rw.CloudEventWriter<org.apache.kafka.clients.producer.ProducerRecord<Void,byte[]>>,org.apache.kafka.clients.producer.ProducerRecord<Void,byte[]>> createWriter(String topic)
Copyright © 2024. All rights reserved.