Class OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>
java.lang.Object
io.smallrye.reactive.messaging.kafka.api.OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>
- Type Parameters:
K- the Kafka record key type
- Enclosing class:
OutgoingKafkaRecordMetadata<K>
public static class OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K>
extends Object
Builder to create
OutgoingKafkaRecordMetadata instances-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddHeaders(org.apache.kafka.common.header.internals.RecordHeader... headers) Add headers for the Kafka recordbuild()Create theOutgoingKafkaRecordMetadatainstance based on the values set in this builderprotected org.apache.kafka.common.header.Headersprotected intprotected Kprotected Instantprotected StringgetTopic()withHeaders(List<org.apache.kafka.common.header.internals.RecordHeader> headers) Specify the headers for the Kafka recordwithHeaders(org.apache.kafka.common.header.Headers headers) Specify headers for the Kafka recordSet the Kafka record keywithPartition(int partition) In most cases Kafka's partitioner should be used to chose the Kafka partition.withTimestamp(Instant timestamp) Specify the timestamp for the Kafka recordBy default the hardcoded topic in the configuration is used.
-
Constructor Details
-
OutgoingKafkaRecordMetadataBuilder
public OutgoingKafkaRecordMetadataBuilder()
-
-
Method Details
-
withTopic
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
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 the Kafka record- Parameters:
headers- the headers- Returns:
- this builder
-
addHeaders
public OutgoingKafkaRecordMetadata.OutgoingKafkaRecordMetadataBuilder<K> addHeaders(org.apache.kafka.common.header.internals.RecordHeader... headers) Add headers 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
-
getRecordKey
-
getPartition
protected int getPartition() -
getTimestamp
-
getHeaders
protected org.apache.kafka.common.header.Headers getHeaders() -
build
Create theOutgoingKafkaRecordMetadatainstance based on the values set in this builder- Returns:
- a new
OutgoingKafkaRecordMetadatainstance
-