Class OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>
- java.lang.Object
-
- io.smallrye.reactive.messaging.kafka.api.OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>
-
- Type Parameters:
K- the Kafka record key type
- Direct Known Subclasses:
OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder
- Enclosing class:
- OutgoingKafkaRecordMetadata<K>
public static class OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K> extends Object
Builder to createOutgoingKafkaRecordMetadatainstances
-
-
Constructor Summary
Constructors Constructor Description OutgoingKafkaRecordMetadataBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OutgoingKafkaRecordMetadata<K>build()Create theOutgoingKafkaRecordMetadatainstance based on the values set in this builderprotected org.apache.kafka.common.header.HeadersgetHeaders()protected intgetPartition()protected KgetRecordKey()protected InstantgetTimestamp()protected StringgetTopic()OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>withHeaders(List<org.apache.kafka.common.header.internals.RecordHeader> headers)Specify the headers for the Kafka recordOutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>withHeaders(org.apache.kafka.common.header.Headers headers)Specify headers for Kafka the timestamp for the Kafka recordOutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>withKey(K recordKey)Set the Kafka record keyOutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>withPartition(int partition)In most cases Kafka's partitioner should be used to chose the Kafka partition.OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>withTimestamp(Instant timestamp)Specify the timestamp for the Kafka recordOutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>withTopic(String topic)By default the hardcoded topic in the configuration is used.
-
-
-
Method Detail
-
withTopic
public OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K> withTopic(String topic)
By default the hardcoded topic in the configuration is used. If decisions need to be made dynamically about which topic to use, it may be specified here.- Parameters:
topic- the topic name- Returns:
- this builder
-
withKey
public OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K> withKey(K recordKey)
Set the Kafka record key- Parameters:
recordKey- the key- Returns:
- this builder
-
withPartition
public OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K> withPartition(int partition)
In most cases Kafka's partitioner should be used to chose the Kafka partition. Im cases where that is not suitable, it may be specified here.- Parameters:
partition- the partition to use- Returns:
- this builder
-
withTimestamp
public OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K> withTimestamp(Instant timestamp)
Specify the timestamp for the Kafka record- Parameters:
timestamp- the timestamp- Returns:
- this builder
-
withHeaders
public OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K> withHeaders(org.apache.kafka.common.header.Headers headers)
Specify headers for Kafka the timestamp for the Kafka record- Parameters:
headers- the headers- Returns:
- this builder
-
withHeaders
public OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K> withHeaders(List<org.apache.kafka.common.header.internals.RecordHeader> headers)
Specify the headers for the Kafka record- Parameters:
headers- the headers- Returns:
- this builder
-
getTopic
protected String getTopic()
-
getRecordKey
protected K getRecordKey()
-
getPartition
protected int getPartition()
-
getTimestamp
protected Instant getTimestamp()
-
getHeaders
protected org.apache.kafka.common.header.Headers getHeaders()
-
build
public OutgoingKafkaRecordMetadata<K> build()
Create theOutgoingKafkaRecordMetadatainstance based on the values set in this builder- Returns:
- a new
OutgoingKafkaRecordMetadatainstance
-
-