io.vertx.reactivex.kafka.client.consumer.KafkaConsumer Maven / Gradle / Ivy
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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.reactivex.kafka.client.consumer;
import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
/**
* Vert.x Kafka consumer.
*
* You receive Kafka records by providing a {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#handler}. As messages arrive the handler
* will be called with the records.
*
* The {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#pause} and {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#resume} provides global control over reading the records from the consumer.
*
* The {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#pause} and {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#resume} provides finer grained control over reading records
* for specific Topic/Partition, these are Kafka's specific operations.
*
*
* NOTE: This class has been automatically generated from the {@link io.vertx.kafka.client.consumer.KafkaConsumer original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.kafka.client.consumer.KafkaConsumer.class)
public class KafkaConsumer implements io.vertx.reactivex.core.streams.ReadStream> {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
KafkaConsumer that = (KafkaConsumer) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new KafkaConsumer((io.vertx.kafka.client.consumer.KafkaConsumer) obj),
KafkaConsumer::getDelegate
);
private final io.vertx.kafka.client.consumer.KafkaConsumer delegate;
public final TypeArg __typeArg_0;
public final TypeArg __typeArg_1;
public KafkaConsumer(io.vertx.kafka.client.consumer.KafkaConsumer delegate) {
this.delegate = delegate;
this.__typeArg_0 = TypeArg.unknown(); this.__typeArg_1 = TypeArg.unknown(); }
public KafkaConsumer(Object delegate, TypeArg typeArg_0, TypeArg typeArg_1) {
this.delegate = (io.vertx.kafka.client.consumer.KafkaConsumer)delegate;
this.__typeArg_0 = typeArg_0;
this.__typeArg_1 = typeArg_1;
}
public io.vertx.kafka.client.consumer.KafkaConsumer getDelegate() {
return delegate;
}
private io.reactivex.Observable> observable;
private io.reactivex.Flowable> flowable;
public synchronized io.reactivex.Observable> toObservable() {
if (observable == null) {
Function, io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecord> conv = io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecord::newInstance;
observable = ObservableHelper.toObservable(delegate, conv);
}
return observable;
}
public synchronized io.reactivex.Flowable> toFlowable() {
if (flowable == null) {
Function, io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecord> conv = io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecord::newInstance;
flowable = FlowableHelper.toFlowable(delegate, conv);
}
return flowable;
}
/**
* Pause this stream and return a to transfer the elements of this stream to a destination .
*
* The stream will be resumed when the pipe will be wired to a WriteStream
.
* @return a pipe
*/
public io.vertx.reactivex.core.streams.Pipe> pipe() {
io.vertx.reactivex.core.streams.Pipe> ret = io.vertx.reactivex.core.streams.Pipe.newInstance((io.vertx.core.streams.Pipe)delegate.pipe(), new TypeArg>(o0 -> io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecord.newInstance((io.vertx.kafka.client.consumer.KafkaConsumerRecord)o0, __typeArg_0, __typeArg_1), o0 -> o0.getDelegate()));
return ret;
}
/**
* Pipe this ReadStream
to the WriteStream
.
*
* Elements emitted by this stream will be written to the write stream until this stream ends or fails.
* @param dst the destination write stream
* @return a future notified when the write stream will be ended with the outcome
*/
public io.vertx.core.Future pipeTo(io.vertx.reactivex.core.streams.WriteStream> dst) {
io.vertx.core.Future ret = delegate.pipeTo(dst.getDelegate()).map(val -> val);
return ret;
}
/**
* Pipe this ReadStream
to the WriteStream
.
*
* Elements emitted by this stream will be written to the write stream until this stream ends or fails.
* @param dst the destination write stream
* @return a future notified when the write stream will be ended with the outcome
*/
public io.reactivex.Completable rxPipeTo(io.vertx.reactivex.core.streams.WriteStream> dst) {
return AsyncResultCompletable.toCompletable($handler -> {
this.pipeTo(dst).onComplete($handler);
});
}
/**
* Create a new KafkaConsumer instance
* @param vertx Vert.x instance to use
* @param config Kafka consumer configuration
* @return an instance of the KafkaConsumer
*/
public static io.vertx.reactivex.kafka.client.consumer.KafkaConsumer create(io.vertx.reactivex.core.Vertx vertx, java.util.Map config) {
io.vertx.reactivex.kafka.client.consumer.KafkaConsumer ret = io.vertx.reactivex.kafka.client.consumer.KafkaConsumer.newInstance((io.vertx.kafka.client.consumer.KafkaConsumer)io.vertx.kafka.client.consumer.KafkaConsumer.create(vertx.getDelegate(), config), TypeArg.unknown(), TypeArg.unknown());
return ret;
}
/**
* Create a new KafkaConsumer instance
* @param vertx Vert.x instance to use
* @param config Kafka consumer configuration
* @param keyType class type for the key deserialization
* @param valueType class type for the value deserialization
* @return an instance of the KafkaConsumer
*/
public static io.vertx.reactivex.kafka.client.consumer.KafkaConsumer create(io.vertx.reactivex.core.Vertx vertx, java.util.Map config, java.lang.Class keyType, java.lang.Class valueType) {
io.vertx.reactivex.kafka.client.consumer.KafkaConsumer ret = io.vertx.reactivex.kafka.client.consumer.KafkaConsumer.newInstance((io.vertx.kafka.client.consumer.KafkaConsumer)io.vertx.kafka.client.consumer.KafkaConsumer.create(vertx.getDelegate(), config, io.vertx.lang.reactivex.Helper.unwrap(keyType), io.vertx.lang.reactivex.Helper.unwrap(valueType)), TypeArg.of(keyType), TypeArg.of(valueType));
return ret;
}
/**
* Create a new KafkaConsumer instance
* @param vertx Vert.x instance to use
* @param options Kafka consumer options
* @return an instance of the KafkaConsumer
*/
public static io.vertx.reactivex.kafka.client.consumer.KafkaConsumer create(io.vertx.reactivex.core.Vertx vertx, io.vertx.kafka.client.common.KafkaClientOptions options) {
io.vertx.reactivex.kafka.client.consumer.KafkaConsumer ret = io.vertx.reactivex.kafka.client.consumer.KafkaConsumer.newInstance((io.vertx.kafka.client.consumer.KafkaConsumer)io.vertx.kafka.client.consumer.KafkaConsumer.create(vertx.getDelegate(), options), TypeArg.unknown(), TypeArg.unknown());
return ret;
}
/**
* Create a new KafkaConsumer instance
* @param vertx Vert.x instance to use
* @param options Kafka consumer options
* @param keyType class type for the key deserialization
* @param valueType class type for the value deserialization
* @return an instance of the KafkaConsumer
*/
public static io.vertx.reactivex.kafka.client.consumer.KafkaConsumer create(io.vertx.reactivex.core.Vertx vertx, io.vertx.kafka.client.common.KafkaClientOptions options, java.lang.Class keyType, java.lang.Class valueType) {
io.vertx.reactivex.kafka.client.consumer.KafkaConsumer ret = io.vertx.reactivex.kafka.client.consumer.KafkaConsumer.newInstance((io.vertx.kafka.client.consumer.KafkaConsumer)io.vertx.kafka.client.consumer.KafkaConsumer.create(vertx.getDelegate(), options, io.vertx.lang.reactivex.Helper.unwrap(keyType), io.vertx.lang.reactivex.Helper.unwrap(valueType)), TypeArg.of(keyType), TypeArg.of(valueType));
return ret;
}
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer exceptionHandler(io.vertx.core.Handler handler) {
delegate.exceptionHandler(handler);
return this;
}
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer handler(io.vertx.core.Handler> handler) {
delegate.handler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecord.newInstance((io.vertx.kafka.client.consumer.KafkaConsumerRecord)event, __typeArg_0, __typeArg_1)));
return this;
}
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer pause() {
delegate.pause();
return this;
}
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer resume() {
delegate.resume();
return this;
}
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer fetch(long amount) {
delegate.fetch(amount);
return this;
}
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer endHandler(io.vertx.core.Handler endHandler) {
delegate.endHandler(endHandler);
return this;
}
/**
* Returns the current demand.
*
*
* If the stream is in flowing mode will return {@link java.lang.Long}.
* - If the stream is in fetch mode, will return the current number of elements still to be delivered or 0 if paused.
*
* @return current demand
*/
public long demand() {
long ret = delegate.demand();
return ret;
}
/**
* Subscribe to the given topic to get dynamically assigned partitions.
*
* Due to internal buffering of messages, when changing the subscribed topic
* the old topic may remain in effect
* (as observed by the record handler})
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new topic.
* @param topic topic to subscribe to
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future subscribe(java.lang.String topic) {
io.vertx.core.Future ret = delegate.subscribe(topic).map(val -> val);
return ret;
}
/**
* Subscribe to the given topic to get dynamically assigned partitions.
*
* Due to internal buffering of messages, when changing the subscribed topic
* the old topic may remain in effect
* (as observed by the record handler})
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new topic.
* @param topic topic to subscribe to
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxSubscribe(java.lang.String topic) {
return AsyncResultCompletable.toCompletable($handler -> {
this.subscribe(topic).onComplete($handler);
});
}
/**
* Subscribe to the given list of topics to get dynamically assigned partitions.
*
* Due to internal buffering of messages, when changing the subscribed topics
* the old set of topics may remain in effect
* (as observed by the record handler})
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new set of topics.
* @param topics topics to subscribe to
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future subscribe(java.util.Set topics) {
io.vertx.core.Future ret = delegate.subscribe(topics).map(val -> val);
return ret;
}
/**
* Subscribe to the given list of topics to get dynamically assigned partitions.
*
* Due to internal buffering of messages, when changing the subscribed topics
* the old set of topics may remain in effect
* (as observed by the record handler})
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new set of topics.
* @param topics topics to subscribe to
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxSubscribe(java.util.Set topics) {
return AsyncResultCompletable.toCompletable($handler -> {
this.subscribe(topics).onComplete($handler);
});
}
/**
* Manually assign a partition to this consumer.
*
* Due to internal buffering of messages, when reassigning
* the old partition may remain in effect
* (as observed by the record handler)}
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new partition.
* @param topicPartition partition which want assigned
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future assign(io.vertx.kafka.client.common.TopicPartition topicPartition) {
io.vertx.core.Future ret = delegate.assign(topicPartition).map(val -> val);
return ret;
}
/**
* Manually assign a partition to this consumer.
*
* Due to internal buffering of messages, when reassigning
* the old partition may remain in effect
* (as observed by the record handler)}
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new partition.
* @param topicPartition partition which want assigned
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxAssign(io.vertx.kafka.client.common.TopicPartition topicPartition) {
return AsyncResultCompletable.toCompletable($handler -> {
this.assign(topicPartition).onComplete($handler);
});
}
/**
* Manually assign a list of partition to this consumer.
*
* Due to internal buffering of messages, when reassigning
* the old set of partitions may remain in effect
* (as observed by the record handler)}
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new set of partitions.
* @param topicPartitions partitions which want assigned
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future assign(java.util.Set topicPartitions) {
io.vertx.core.Future ret = delegate.assign(topicPartitions).map(val -> val);
return ret;
}
/**
* Manually assign a list of partition to this consumer.
*
* Due to internal buffering of messages, when reassigning
* the old set of partitions may remain in effect
* (as observed by the record handler)}
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new set of partitions.
* @param topicPartitions partitions which want assigned
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxAssign(java.util.Set topicPartitions) {
return AsyncResultCompletable.toCompletable($handler -> {
this.assign(topicPartitions).onComplete($handler);
});
}
/**
* Get the set of partitions currently assigned to this consumer.
* @return a future notified on operation completed
*/
public io.vertx.core.Future> assignment() {
io.vertx.core.Future> ret = delegate.assignment().map(val -> val);
return ret;
}
/**
* Get the set of partitions currently assigned to this consumer.
* @return a future notified on operation completed
*/
public io.reactivex.Single> rxAssignment() {
return AsyncResultSingle.toSingle($handler -> {
this.assignment().onComplete($handler);
});
}
/**
* Unsubscribe from topics currently subscribed with subscribe.
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future unsubscribe() {
io.vertx.core.Future ret = delegate.unsubscribe().map(val -> val);
return ret;
}
/**
* Unsubscribe from topics currently subscribed with subscribe.
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxUnsubscribe() {
return AsyncResultCompletable.toCompletable($handler -> {
this.unsubscribe().onComplete($handler);
});
}
/**
* Get the current subscription.
* @return a future notified on operation completed
*/
public io.vertx.core.Future> subscription() {
io.vertx.core.Future> ret = delegate.subscription().map(val -> val);
return ret;
}
/**
* Get the current subscription.
* @return a future notified on operation completed
*/
public io.reactivex.Single> rxSubscription() {
return AsyncResultSingle.toSingle($handler -> {
this.subscription().onComplete($handler);
});
}
/**
* Suspend fetching from the requested partition.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages from the given topicPartition
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages
* from the given topicPartition
.
* @param topicPartition topic partition from which suspend fetching
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future pause(io.vertx.kafka.client.common.TopicPartition topicPartition) {
io.vertx.core.Future ret = delegate.pause(topicPartition).map(val -> val);
return ret;
}
/**
* Suspend fetching from the requested partition.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages from the given topicPartition
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages
* from the given topicPartition
.
* @param topicPartition topic partition from which suspend fetching
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxPause(io.vertx.kafka.client.common.TopicPartition topicPartition) {
return AsyncResultCompletable.toCompletable($handler -> {
this.pause(topicPartition).onComplete($handler);
});
}
/**
* Suspend fetching from the requested partitions.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages from the given topicPartitions
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages
* from the given topicPartitions
.
* @param topicPartitions topic partition from which suspend fetching
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future pause(java.util.Set topicPartitions) {
io.vertx.core.Future ret = delegate.pause(topicPartitions).map(val -> val);
return ret;
}
/**
* Suspend fetching from the requested partitions.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages from the given topicPartitions
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages
* from the given topicPartitions
.
* @param topicPartitions topic partition from which suspend fetching
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxPause(java.util.Set topicPartitions) {
return AsyncResultCompletable.toCompletable($handler -> {
this.pause(topicPartitions).onComplete($handler);
});
}
/**
* Get the set of partitions that were previously paused by a call to pause(Set).
* @return a future notified on operation completed
*/
public io.vertx.core.Future> paused() {
io.vertx.core.Future> ret = delegate.paused().map(val -> val);
return ret;
}
/**
* Get the set of partitions that were previously paused by a call to pause(Set).
* @return a future notified on operation completed
*/
public io.reactivex.Single> rxPaused() {
return AsyncResultSingle.toSingle($handler -> {
this.paused().onComplete($handler);
});
}
/**
* Resume specified partition which have been paused with pause.
* @param topicPartition topic partition from which resume fetching
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future resume(io.vertx.kafka.client.common.TopicPartition topicPartition) {
io.vertx.core.Future ret = delegate.resume(topicPartition).map(val -> val);
return ret;
}
/**
* Resume specified partition which have been paused with pause.
* @param topicPartition topic partition from which resume fetching
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxResume(io.vertx.kafka.client.common.TopicPartition topicPartition) {
return AsyncResultCompletable.toCompletable($handler -> {
this.resume(topicPartition).onComplete($handler);
});
}
/**
* Resume specified partitions which have been paused with pause.
* @param topicPartitions topic partition from which resume fetching
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future resume(java.util.Set topicPartitions) {
io.vertx.core.Future ret = delegate.resume(topicPartitions).map(val -> val);
return ret;
}
/**
* Resume specified partitions which have been paused with pause.
* @param topicPartitions topic partition from which resume fetching
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxResume(java.util.Set topicPartitions) {
return AsyncResultCompletable.toCompletable($handler -> {
this.resume(topicPartitions).onComplete($handler);
});
}
/**
* Set the handler called when topic partitions are revoked to the consumer
* @param handler handler called on revoked topic partitions
* @return current KafkaConsumer instance
*/
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer partitionsRevokedHandler(io.vertx.core.Handler> handler) {
delegate.partitionsRevokedHandler(handler);
return this;
}
/**
* Set the handler called when topic partitions are assigned to the consumer
* @param handler handler called on assigned topic partitions
* @return current KafkaConsumer instance
*/
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer partitionsAssignedHandler(io.vertx.core.Handler> handler) {
delegate.partitionsAssignedHandler(handler);
return this;
}
/**
* Overrides the fetch offsets that the consumer will use on the next poll.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartition topic partition for which seek
* @param offset offset to seek inside the topic partition
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future seek(io.vertx.kafka.client.common.TopicPartition topicPartition, long offset) {
io.vertx.core.Future ret = delegate.seek(topicPartition, offset).map(val -> val);
return ret;
}
/**
* Overrides the fetch offsets that the consumer will use on the next poll.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartition topic partition for which seek
* @param offset offset to seek inside the topic partition
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxSeek(io.vertx.kafka.client.common.TopicPartition topicPartition, long offset) {
return AsyncResultCompletable.toCompletable($handler -> {
this.seek(topicPartition, offset).onComplete($handler);
});
}
/**
* Overrides the fetch offsets that the consumer will use on the next poll.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartition topic partition for which seek
* @param offsetAndMetadata offset to seek inside the topic partition
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future seek(io.vertx.kafka.client.common.TopicPartition topicPartition, io.vertx.kafka.client.consumer.OffsetAndMetadata offsetAndMetadata) {
io.vertx.core.Future ret = delegate.seek(topicPartition, offsetAndMetadata).map(val -> val);
return ret;
}
/**
* Overrides the fetch offsets that the consumer will use on the next poll.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartition topic partition for which seek
* @param offsetAndMetadata offset to seek inside the topic partition
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxSeek(io.vertx.kafka.client.common.TopicPartition topicPartition, io.vertx.kafka.client.consumer.OffsetAndMetadata offsetAndMetadata) {
return AsyncResultCompletable.toCompletable($handler -> {
this.seek(topicPartition, offsetAndMetadata).onComplete($handler);
});
}
/**
* Seek to the first offset for each of the given partition.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartition topic partition for which seek
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future seekToBeginning(io.vertx.kafka.client.common.TopicPartition topicPartition) {
io.vertx.core.Future ret = delegate.seekToBeginning(topicPartition).map(val -> val);
return ret;
}
/**
* Seek to the first offset for each of the given partition.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartition topic partition for which seek
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxSeekToBeginning(io.vertx.kafka.client.common.TopicPartition topicPartition) {
return AsyncResultCompletable.toCompletable($handler -> {
this.seekToBeginning(topicPartition).onComplete($handler);
});
}
/**
* Seek to the first offset for each of the given partitions.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartitions topic partition for which seek
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future seekToBeginning(java.util.Set topicPartitions) {
io.vertx.core.Future ret = delegate.seekToBeginning(topicPartitions).map(val -> val);
return ret;
}
/**
* Seek to the first offset for each of the given partitions.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartitions topic partition for which seek
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxSeekToBeginning(java.util.Set topicPartitions) {
return AsyncResultCompletable.toCompletable($handler -> {
this.seekToBeginning(topicPartitions).onComplete($handler);
});
}
/**
* Seek to the last offset for each of the given partition.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartition topic partition for which seek
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future seekToEnd(io.vertx.kafka.client.common.TopicPartition topicPartition) {
io.vertx.core.Future ret = delegate.seekToEnd(topicPartition).map(val -> val);
return ret;
}
/**
* Seek to the last offset for each of the given partition.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartition topic partition for which seek
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxSeekToEnd(io.vertx.kafka.client.common.TopicPartition topicPartition) {
return AsyncResultCompletable.toCompletable($handler -> {
this.seekToEnd(topicPartition).onComplete($handler);
});
}
/**
* Seek to the last offset for each of the given partitions.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartitions topic partition for which seek
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future seekToEnd(java.util.Set topicPartitions) {
io.vertx.core.Future ret = delegate.seekToEnd(topicPartitions).map(val -> val);
return ret;
}
/**
* Seek to the last offset for each of the given partitions.
*
* Due to internal buffering of messages,
* the will
* continue to observe messages fetched with respect to the old offset
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new offset.
* @param topicPartitions topic partition for which seek
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxSeekToEnd(java.util.Set topicPartitions) {
return AsyncResultCompletable.toCompletable($handler -> {
this.seekToEnd(topicPartitions).onComplete($handler);
});
}
/**
* Commit current offsets for all the subscribed list of topics and partition.
* @return
*/
public io.vertx.core.Future commit() {
io.vertx.core.Future ret = delegate.commit().map(val -> val);
return ret;
}
/**
* Commit current offsets for all the subscribed list of topics and partition.
* @return
*/
public io.reactivex.Completable rxCommit() {
return AsyncResultCompletable.toCompletable($handler -> {
this.commit().onComplete($handler);
});
}
/**
* Get the last committed offset for the given partition (whether the commit happened by this process or another).
* @param topicPartition topic partition for getting last committed offset
* @return a future notified on operation completed
*/
public io.vertx.core.Future committed(io.vertx.kafka.client.common.TopicPartition topicPartition) {
io.vertx.core.Future ret = delegate.committed(topicPartition).map(val -> val);
return ret;
}
/**
* Get the last committed offset for the given partition (whether the commit happened by this process or another).
* @param topicPartition topic partition for getting last committed offset
* @return a future notified on operation completed
*/
public io.reactivex.Single rxCommitted(io.vertx.kafka.client.common.TopicPartition topicPartition) {
return AsyncResultSingle.toSingle($handler -> {
this.committed(topicPartition).onComplete($handler);
});
}
/**
* Get metadata about the partitions for a given topic.
* @param topic topic partition for which getting partitions info
* @return a future notified on operation completed
*/
public io.vertx.core.Future> partitionsFor(java.lang.String topic) {
io.vertx.core.Future> ret = delegate.partitionsFor(topic).map(val -> val);
return ret;
}
/**
* Get metadata about the partitions for a given topic.
* @param topic topic partition for which getting partitions info
* @return a future notified on operation completed
*/
public io.reactivex.Single> rxPartitionsFor(java.lang.String topic) {
return AsyncResultSingle.toSingle($handler -> {
this.partitionsFor(topic).onComplete($handler);
});
}
/**
* Set the handler to be used when batches of messages are fetched
* from the Kafka server. Batch handlers need to take care not to block
* the event loop when dealing with large batches. It is better to process
* records individually using the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer #handler(Handler) record handler}.
* @param handler handler called when batches of messages are fetched
* @return current KafkaConsumer instance
*/
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer batchHandler(io.vertx.core.Handler> handler) {
delegate.batchHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords.newInstance((io.vertx.kafka.client.consumer.KafkaConsumerRecords)event, __typeArg_0, __typeArg_1)));
return this;
}
/**
* Close the consumer
* @return
*/
public io.vertx.core.Future close() {
io.vertx.core.Future ret = delegate.close().map(val -> val);
return ret;
}
/**
* Close the consumer
* @return
*/
public io.reactivex.Completable rxClose() {
return AsyncResultCompletable.toCompletable($handler -> {
this.close().onComplete($handler);
});
}
/**
* Get the offset of the next record that will be fetched (if a record with that offset exists).
* @param partition The partition to get the position for
* @return a future notified on operation completed
*/
public io.vertx.core.Future position(io.vertx.kafka.client.common.TopicPartition partition) {
io.vertx.core.Future ret = delegate.position(partition).map(val -> val);
return ret;
}
/**
* Get the offset of the next record that will be fetched (if a record with that offset exists).
* @param partition The partition to get the position for
* @return a future notified on operation completed
*/
public io.reactivex.Single rxPosition(io.vertx.kafka.client.common.TopicPartition partition) {
return AsyncResultSingle.toSingle($handler -> {
this.position(partition).onComplete($handler);
});
}
/**
* Look up the offset for the given partition by timestamp. Note: the result might be null in case
* for the given timestamp no offset can be found -- e.g., when the timestamp refers to the future
* @param topicPartition TopicPartition to query.
* @param timestamp Timestamp to be used in the query.
* @return a future notified on operation completed
*/
public io.vertx.core.Future offsetsForTimes(io.vertx.kafka.client.common.TopicPartition topicPartition, java.lang.Long timestamp) {
io.vertx.core.Future ret = delegate.offsetsForTimes(topicPartition, timestamp).map(val -> val);
return ret;
}
/**
* Look up the offset for the given partition by timestamp. Note: the result might be null in case
* for the given timestamp no offset can be found -- e.g., when the timestamp refers to the future
* @param topicPartition TopicPartition to query.
* @param timestamp Timestamp to be used in the query.
* @return a future notified on operation completed
*/
public io.reactivex.Single rxOffsetsForTimes(io.vertx.kafka.client.common.TopicPartition topicPartition, java.lang.Long timestamp) {
return AsyncResultSingle.toSingle($handler -> {
this.offsetsForTimes(topicPartition, timestamp).onComplete($handler);
});
}
/**
* Get the first offset for the given partitions.
* @param topicPartition the partition to get the earliest offset.
* @return a future notified on operation completed
*/
public io.vertx.core.Future beginningOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition) {
io.vertx.core.Future ret = delegate.beginningOffsets(topicPartition).map(val -> val);
return ret;
}
/**
* Get the first offset for the given partitions.
* @param topicPartition the partition to get the earliest offset.
* @return a future notified on operation completed
*/
public io.reactivex.Single rxBeginningOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition) {
return AsyncResultSingle.toSingle($handler -> {
this.beginningOffsets(topicPartition).onComplete($handler);
});
}
/**
* Get the last offset for the given partition. The last offset of a partition is the offset
* of the upcoming message, i.e. the offset of the last available message + 1.
* @param topicPartition the partition to get the end offset.
* @return a future notified on operation completed
*/
public io.vertx.core.Future endOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition) {
io.vertx.core.Future ret = delegate.endOffsets(topicPartition).map(val -> val);
return ret;
}
/**
* Get the last offset for the given partition. The last offset of a partition is the offset
* of the upcoming message, i.e. the offset of the last available message + 1.
* @param topicPartition the partition to get the end offset.
* @return a future notified on operation completed
*/
public io.reactivex.Single rxEndOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition) {
return AsyncResultSingle.toSingle($handler -> {
this.endOffsets(topicPartition).onComplete($handler);
});
}
/**
* Create a new KafkaConsumer instance from a native .
* @param vertx Vert.x instance to use
* @param consumer the Kafka consumer to wrap
* @return an instance of the KafkaConsumer
*/
public static io.vertx.reactivex.kafka.client.consumer.KafkaConsumer create(io.vertx.reactivex.core.Vertx vertx, org.apache.kafka.clients.consumer.Consumer consumer) {
io.vertx.reactivex.kafka.client.consumer.KafkaConsumer ret = io.vertx.reactivex.kafka.client.consumer.KafkaConsumer.newInstance((io.vertx.kafka.client.consumer.KafkaConsumer)io.vertx.kafka.client.consumer.KafkaConsumer.create(vertx.getDelegate(), consumer), TypeArg.unknown(), TypeArg.unknown());
return ret;
}
/**
* Create a new KafkaConsumer instance from a native .
* @param vertx Vert.x instance to use
* @param consumer the Kafka consumer to wrap
* @param options options used only for tracing settings
* @return an instance of the KafkaConsumer
*/
public static io.vertx.reactivex.kafka.client.consumer.KafkaConsumer create(io.vertx.reactivex.core.Vertx vertx, org.apache.kafka.clients.consumer.Consumer consumer, io.vertx.kafka.client.common.KafkaClientOptions options) {
io.vertx.reactivex.kafka.client.consumer.KafkaConsumer ret = io.vertx.reactivex.kafka.client.consumer.KafkaConsumer.newInstance((io.vertx.kafka.client.consumer.KafkaConsumer)io.vertx.kafka.client.consumer.KafkaConsumer.create(vertx.getDelegate(), consumer, options), TypeArg.unknown(), TypeArg.unknown());
return ret;
}
/**
* Subscribe to all topics matching specified pattern to get dynamically assigned partitions.
*
* Due to internal buffering of messages, when changing the subscribed topics
* the old set of topics may remain in effect
* (as observed by the record handler})
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new set of topics.
* @param pattern Pattern to subscribe to
* @return a Future
completed with the operation result
*/
public io.vertx.core.Future subscribe(java.util.regex.Pattern pattern) {
io.vertx.core.Future ret = delegate.subscribe(pattern).map(val -> val);
return ret;
}
/**
* Subscribe to all topics matching specified pattern to get dynamically assigned partitions.
*
* Due to internal buffering of messages, when changing the subscribed topics
* the old set of topics may remain in effect
* (as observed by the record handler})
* until some time after the given completionHandler
* is called. In contrast, the once the given completionHandler
* is called the {@link io.vertx.reactivex.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages
* consistent with the new set of topics.
* @param pattern Pattern to subscribe to
* @return a Future
completed with the operation result
*/
public io.reactivex.Completable rxSubscribe(java.util.regex.Pattern pattern) {
return AsyncResultCompletable.toCompletable($handler -> {
this.subscribe(pattern).onComplete($handler);
});
}
/**
* Sets the poll timeout for the underlying native Kafka Consumer. Defaults to 1000ms.
* Setting timeout to a lower value results in a more 'responsive' client, because it will block for a shorter period
* if no data is available in the assigned partition and therefore allows subsequent actions to be executed with a shorter
* delay. At the same time, the client will poll more frequently and thus will potentially create a higher load on the Kafka Broker.
* @param timeout The time, spent waiting in poll if data is not available in the buffer. If 0, returns immediately with any records that are available currently in the native Kafka consumer's buffer, else returns empty. Must not be negative.
* @return
*/
public io.vertx.reactivex.kafka.client.consumer.KafkaConsumer pollTimeout(java.time.Duration timeout) {
delegate.pollTimeout(timeout);
return this;
}
/**
* Executes a poll for getting messages from Kafka.
* @param timeout The maximum time to block (must not be greater than {@link java.lang.Long} milliseconds)
* @return a future notified on operation completed
*/
public io.vertx.core.Future> poll(java.time.Duration timeout) {
io.vertx.core.Future> ret = delegate.poll(timeout).map(val -> io.vertx.reactivex.kafka.client.consumer.KafkaConsumerRecords.newInstance((io.vertx.kafka.client.consumer.KafkaConsumerRecords)val, __typeArg_0, __typeArg_1));
return ret;
}
/**
* Executes a poll for getting messages from Kafka.
* @param timeout The maximum time to block (must not be greater than {@link java.lang.Long} milliseconds)
* @return a future notified on operation completed
*/
public io.reactivex.Single> rxPoll(java.time.Duration timeout) {
return AsyncResultSingle.toSingle($handler -> {
this.poll(timeout).onComplete($handler);
});
}
public static KafkaConsumer newInstance(io.vertx.kafka.client.consumer.KafkaConsumer arg) {
return arg != null ? new KafkaConsumer(arg) : null;
}
public static KafkaConsumer newInstance(io.vertx.kafka.client.consumer.KafkaConsumer arg, TypeArg __typeArg_K, TypeArg __typeArg_V) {
return arg != null ? new KafkaConsumer(arg, __typeArg_K, __typeArg_V) : null;
}
}