All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.streamnative.kafka.client.three.zero.Producer300Impl Maven / Gradle / Ivy

There is a newer version: 3.3.1.5
Show newest version
/**
 * 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.streamnative.kafka.client.three.zero;

import io.streamnative.kafka.client.api.ProduceContext;
import io.streamnative.kafka.client.api.Producer;
import io.streamnative.kafka.client.api.ProducerConfiguration;
import io.streamnative.kafka.client.api.RecordMetadata;
import java.util.concurrent.Future;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.header.internals.RecordHeader;

/**
 * The implementation of Kafka producer 3.0.0.
 */
public class Producer300Impl extends KafkaProducer implements Producer {

    public Producer300Impl(final ProducerConfiguration conf) {
        super(conf.toProperties());
    }

    @SuppressWarnings("unchecked")
    @Override
    public Future sendAsync(final ProduceContext context) {
        send(context.createV2ProducerRecord(ProducerRecord.class, RecordHeader::new), context::complete);
        return context.getFuture();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy