/*
 * Copyright 2016 Red Hat Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.vertx.kafka.client.producer;

import io.vertx.codegen.annotations.CacheReturn;
import io.vertx.codegen.annotations.Fluent;
import io.vertx.codegen.annotations.GenIgnore;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.buffer.Buffer;
import io.vertx.kafka.client.producer.impl.KafkaProducerRecordImpl;
import org.apache.kafka.clients.producer.ProducerRecord;

import java.util.List;

Vert.x Kafka producer record.
/** * Vert.x Kafka producer record. */
@VertxGen public interface KafkaProducerRecord<K, V> {
Create a concrete instance of a Vert.x producer record
Params:
  • topic – the topic this record is being sent to
  • key – the key (or null if no key is specified)
  • value – the value
  • timestamp – the timestamp of this record
  • partition – the partition to which the record will be sent (or null if no partition was specified)
Type parameters:
  • <K> – key type
  • <V> – value type
Returns: Vert.x producer record
/** * Create a concrete instance of a Vert.x producer record * * @param topic the topic this record is being sent to * @param key the key (or null if no key is specified) * @param value the value * @param timestamp the timestamp of this record * @param partition the partition to which the record will be sent (or null if no partition was specified) * @param <K> key type * @param <V> value type * @return Vert.x producer record */
static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Long timestamp, Integer partition) { return new KafkaProducerRecordImpl<>(topic, key, value, timestamp, partition); }
Create a concrete instance of a Vert.x producer record
Params:
  • topic – the topic this record is being sent to
  • key – the key (or null if no key is specified)
  • value – the value
  • partition – the partition to which the record will be sent (or null if no partition was specified)
Type parameters:
  • <K> – key type
  • <V> – value type
Returns: Vert.x producer record
/** * Create a concrete instance of a Vert.x producer record * * @param topic the topic this record is being sent to * @param key the key (or null if no key is specified) * @param value the value * @param partition the partition to which the record will be sent (or null if no partition was specified) * @param <K> key type * @param <V> value type * @return Vert.x producer record */
@GenIgnore static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value, Integer partition) { return new KafkaProducerRecordImpl<>(topic, key, value, partition); }
Create a concrete instance of a Vert.x producer record
Params:
  • topic – the topic this record is being sent to
  • key – the key (or null if no key is specified)
  • value – the value
Type parameters:
  • <K> – key type
  • <V> – value type
Returns: Vert.x producer record
/** * Create a concrete instance of a Vert.x producer record * * @param topic the topic this record is being sent to * @param key the key (or null if no key is specified) * @param value the value * @param <K> key type * @param <V> value type * @return Vert.x producer record */
static <K, V> KafkaProducerRecord<K, V> create(String topic, K key, V value) { return new KafkaProducerRecordImpl<>(topic, key, value); }
Create a concrete instance of a Vert.x producer record
Params:
  • topic – the topic this record is being sent to
  • value – the value
Type parameters:
  • <K> – key type
  • <V> – value type
Returns: Vert.x producer record
/** * Create a concrete instance of a Vert.x producer record * * @param topic the topic this record is being sent to * @param value the value * @param <K> key type * @param <V> value type * @return Vert.x producer record */
static <K, V> KafkaProducerRecord<K, V> create(String topic, V value) { return new KafkaProducerRecordImpl<>(topic, value); }
Returns: the topic this record is being sent to
/** * @return the topic this record is being sent to */
String topic();
Returns: the key (or null if no key is specified)
/** * @return the key (or null if no key is specified) */
K key();
Returns: the value
/** * @return the value */
V value();
Returns: the timestamp of this record
/** * @return the timestamp of this record */
Long timestamp();
Returns: the partition to which the record will be sent (or null if no partition was specified)
/** * @return the partition to which the record will be sent (or null if no partition was specified) */
Integer partition();
Like addHeader(KafkaHeader) but with a key/value pair
/** * Like {@link #addHeader(KafkaHeader)} but with a key/value pair */
@Fluent KafkaProducerRecord<K, V> addHeader(String key, String value);
Like addHeader(KafkaHeader) but with a key/value pair
/** * Like {@link #addHeader(KafkaHeader)} but with a key/value pair */
@Fluent KafkaProducerRecord<K, V> addHeader(String key, Buffer value);
Add an header to this record.
Params:
  • header – the header
Returns: current KafkaProducerRecord instance
/** * Add an header to this record. * * @param header the header * @return current KafkaProducerRecord instance */
@Fluent KafkaProducerRecord<K, V> addHeader(KafkaHeader header);
Add a list of headers to this record.
Params:
  • headers – the headers
Returns: current KafkaProducerRecord instance
/** * Add a list of headers to this record. * * @param headers the headers * @return current KafkaProducerRecord instance */
@Fluent KafkaProducerRecord<K, V> addHeaders(List<KafkaHeader> headers);
Returns: the headers of this record
/** * @return the headers of this record */
@CacheReturn List<KafkaHeader> headers();
Returns:a created native Kafka producer record with backed information
/** * @return a created native Kafka producer record with backed information */
@GenIgnore ProducerRecord<K, V> record(); }