java.lang.Object
io.cloudevents.kafka.PartitionKeyExtensionInterceptor
- All Implemented Interfaces:
AutoCloseable,ProducerInterceptor<Object,,io.cloudevents.CloudEvent> Configurable
public class PartitionKeyExtensionInterceptor
extends Object
implements ProducerInterceptor<Object,io.cloudevents.CloudEvent>
This
ProducerInterceptor implements the partitioning extension,
as described in the CloudEvents Kafka specification.
When using in your KafkaProducer,
it will pick the partitionkey extension from the event and will set it as record key.
If the extension is missing, It won't replace the key from the original record.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe extension key of partition key extension. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidvoidonAcknowledgement(RecordMetadata metadata, Exception exception) ProducerRecord<Object,io.cloudevents.CloudEvent> onSend(ProducerRecord<Object, io.cloudevents.CloudEvent> record) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.kafka.clients.producer.ProducerInterceptor
onAcknowledgement
-
Field Details
-
PARTITION_KEY_EXTENSION
The extension key of partition key extension.- See Also:
-
-
Constructor Details
-
PartitionKeyExtensionInterceptor
public PartitionKeyExtensionInterceptor()
-
-
Method Details
-
onSend
public ProducerRecord<Object,io.cloudevents.CloudEvent> onSend(ProducerRecord<Object, io.cloudevents.CloudEvent> record) - Specified by:
onSendin interfaceProducerInterceptor<Object,io.cloudevents.CloudEvent>
-
onAcknowledgement
- Specified by:
onAcknowledgementin interfaceProducerInterceptor<Object,io.cloudevents.CloudEvent>
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceProducerInterceptor<Object,io.cloudevents.CloudEvent>
-
configure
- Specified by:
configurein interfaceConfigurable
-