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

io.vertx.rxjava.kafka.client.consumer.KafkaConsumer Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR1
Show newest version
/*
 * 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.rxjava.kafka.client.consumer;

import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
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.rxjava.kafka.client.consumer.KafkaConsumer#handler}. As messages arrive the handler * will be called with the records. *

* The {@link io.vertx.rxjava.kafka.client.consumer.KafkaConsumer#pause} and {@link io.vertx.rxjava.kafka.client.consumer.KafkaConsumer#resume} provides global control over reading the records from the consumer. *

* The {@link io.vertx.rxjava.kafka.client.consumer.KafkaConsumer#pause} and {@link io.vertx.rxjava.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.rxjava.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 Observable> observable; public synchronized Observable> toObservable() { if (observable == null) { Function, io.vertx.rxjava.kafka.client.consumer.KafkaConsumerRecord> conv = io.vertx.rxjava.kafka.client.consumer.KafkaConsumerRecord::newInstance; observable = RxHelper.toObservable(delegate, conv); } return observable; } /** * 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.rxjava.core.streams.Pipe> pipe() { io.vertx.rxjava.core.streams.Pipe> ret = io.vertx.rxjava.core.streams.Pipe.newInstance((io.vertx.core.streams.Pipe)delegate.pipe(), new TypeArg>(o0 -> io.vertx.rxjava.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. *

* Once this stream has ended or failed, the write stream will be ended and the handler will be * called with the result. * @param dst the destination write stream * @param handler */ public void pipeTo(io.vertx.rxjava.core.streams.WriteStream> dst, Handler> handler) { delegate.pipeTo(dst.getDelegate(), handler); } /** * Pipe this ReadStream to the WriteStream. *

* Elements emitted by this stream will be written to the write stream until this stream ends or fails. *

* Once this stream has ended or failed, the write stream will be ended and the handler will be * called with the result. * @param dst the destination write stream */ public void pipeTo(io.vertx.rxjava.core.streams.WriteStream> dst) { pipeTo(dst, ar -> { }); } /** * Pipe this ReadStream to the WriteStream. *

* Elements emitted by this stream will be written to the write stream until this stream ends or fails. *

* Once this stream has ended or failed, the write stream will be ended and the handler will be * called with the result. * @param dst the destination write stream * @return */ public Single rxPipeTo(io.vertx.rxjava.core.streams.WriteStream> dst) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { pipeTo(dst, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer create(io.vertx.rxjava.core.Vertx vertx, java.util.Map config) { io.vertx.rxjava.kafka.client.consumer.KafkaConsumer ret = io.vertx.rxjava.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.rxjava.kafka.client.consumer.KafkaConsumer create(io.vertx.rxjava.core.Vertx vertx, java.util.Map config, java.lang.Class keyType, java.lang.Class valueType) { io.vertx.rxjava.kafka.client.consumer.KafkaConsumer ret = io.vertx.rxjava.kafka.client.consumer.KafkaConsumer.newInstance((io.vertx.kafka.client.consumer.KafkaConsumer)io.vertx.kafka.client.consumer.KafkaConsumer.create(vertx.getDelegate(), config, io.vertx.lang.rxjava.Helper.unwrap(keyType), io.vertx.lang.rxjava.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.rxjava.kafka.client.consumer.KafkaConsumer create(io.vertx.rxjava.core.Vertx vertx, io.vertx.kafka.client.common.KafkaClientOptions options) { io.vertx.rxjava.kafka.client.consumer.KafkaConsumer ret = io.vertx.rxjava.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.rxjava.kafka.client.consumer.KafkaConsumer create(io.vertx.rxjava.core.Vertx vertx, io.vertx.kafka.client.common.KafkaClientOptions options, java.lang.Class keyType, java.lang.Class valueType) { io.vertx.rxjava.kafka.client.consumer.KafkaConsumer ret = io.vertx.rxjava.kafka.client.consumer.KafkaConsumer.newInstance((io.vertx.kafka.client.consumer.KafkaConsumer)io.vertx.kafka.client.consumer.KafkaConsumer.create(vertx.getDelegate(), options, io.vertx.lang.rxjava.Helper.unwrap(keyType), io.vertx.lang.rxjava.Helper.unwrap(valueType)), TypeArg.of(keyType), TypeArg.of(valueType)); return ret; } public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer exceptionHandler(Handler handler) { delegate.exceptionHandler(handler); return this; } public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer handler(Handler> handler) { delegate.handler(new Handler>() { public void handle(io.vertx.kafka.client.consumer.KafkaConsumerRecord event) { handler.handle(io.vertx.rxjava.kafka.client.consumer.KafkaConsumerRecord.newInstance((io.vertx.kafka.client.consumer.KafkaConsumerRecord)event, __typeArg_0, __typeArg_1)); } }); return this; } public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer pause() { delegate.pause(); return this; } public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer resume() { delegate.resume(); return this; } public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer fetch(long amount) { delegate.fetch(amount); return this; } public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer endHandler(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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new topic. * @param topic topic to subscribe to * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer subscribe(String topic, Handler> completionHandler) { delegate.subscribe(topic, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new topic. * @param topic topic to subscribe to * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer subscribe(String topic) { return subscribe(topic, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new topic. * @param topic topic to subscribe to * @return current KafkaConsumer instance */ public Single rxSubscribe(String topic) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { subscribe(topic, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new set of topics. * @param topics topics to subscribe to * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer subscribe(Set topics, Handler> completionHandler) { delegate.subscribe(topics, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new set of topics. * @param topics topics to subscribe to * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer subscribe(Set topics) { return subscribe(topics, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new set of topics. * @param topics topics to subscribe to * @return current KafkaConsumer instance */ public Single rxSubscribe(Set topics) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { subscribe(topics, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new partition. * @param topicPartition partition which want assigned * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer assign(io.vertx.kafka.client.common.TopicPartition topicPartition, Handler> completionHandler) { delegate.assign(topicPartition, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new partition. * @param topicPartition partition which want assigned * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer assign(io.vertx.kafka.client.common.TopicPartition topicPartition) { return assign(topicPartition, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new partition. * @param topicPartition partition which want assigned * @return current KafkaConsumer instance */ public Single rxAssign(io.vertx.kafka.client.common.TopicPartition topicPartition) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { assign(topicPartition, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new set of partitions. * @param topicPartitions partitions which want assigned * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer assign(Set topicPartitions, Handler> completionHandler) { delegate.assign(topicPartitions, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new set of partitions. * @param topicPartitions partitions which want assigned * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer assign(Set topicPartitions) { return assign(topicPartitions, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new set of partitions. * @param topicPartitions partitions which want assigned * @return current KafkaConsumer instance */ public Single rxAssign(Set topicPartitions) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { assign(topicPartitions, fut); })); } /** * Get the set of partitions currently assigned to this consumer. * @param handler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer assignment(Handler>> handler) { delegate.assignment(handler); return this; } /** * Get the set of partitions currently assigned to this consumer. * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer assignment() { return assignment(ar -> { }); } /** * Get the set of partitions currently assigned to this consumer. * @return current KafkaConsumer instance */ public Single> rxAssignment() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { assignment(fut); })); } /** * Unsubscribe from topics currently subscribed with subscribe. * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer unsubscribe(Handler> completionHandler) { delegate.unsubscribe(completionHandler); return this; } /** * Unsubscribe from topics currently subscribed with subscribe. * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer unsubscribe() { return unsubscribe(ar -> { }); } /** * Unsubscribe from topics currently subscribed with subscribe. * @return current KafkaConsumer instance */ public Single rxUnsubscribe() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { unsubscribe(fut); })); } /** * Get the current subscription. * @param handler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer subscription(Handler>> handler) { delegate.subscription(handler); return this; } /** * Get the current subscription. * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer subscription() { return subscription(ar -> { }); } /** * Get the current subscription. * @return current KafkaConsumer instance */ public Single> rxSubscription() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { subscription(fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages * from the given topicPartition. * @param topicPartition topic partition from which suspend fetching * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer pause(io.vertx.kafka.client.common.TopicPartition topicPartition, Handler> completionHandler) { delegate.pause(topicPartition, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages * from the given topicPartition. * @param topicPartition topic partition from which suspend fetching * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer pause(io.vertx.kafka.client.common.TopicPartition topicPartition) { return pause(topicPartition, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages * from the given topicPartition. * @param topicPartition topic partition from which suspend fetching * @return current KafkaConsumer instance */ public Single rxPause(io.vertx.kafka.client.common.TopicPartition topicPartition) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { pause(topicPartition, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages * from the given topicPartitions. * @param topicPartitions topic partition from which suspend fetching * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer pause(Set topicPartitions, Handler> completionHandler) { delegate.pause(topicPartitions, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages * from the given topicPartitions. * @param topicPartitions topic partition from which suspend fetching * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer pause(Set topicPartitions) { return pause(topicPartitions, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will not see messages * from the given topicPartitions. * @param topicPartitions topic partition from which suspend fetching * @return current KafkaConsumer instance */ public Single rxPause(Set topicPartitions) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { pause(topicPartitions, fut); })); } /** * Get the set of partitions that were previously paused by a call to pause(Set). * @param handler handler called on operation completed */ public void paused(Handler>> handler) { delegate.paused(handler); } /** * Get the set of partitions that were previously paused by a call to pause(Set). */ public void paused() { paused(ar -> { }); } /** * Get the set of partitions that were previously paused by a call to pause(Set). * @return */ public Single> rxPaused() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { paused(fut); })); } /** * Resume specified partition which have been paused with pause. * @param topicPartition topic partition from which resume fetching * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer resume(io.vertx.kafka.client.common.TopicPartition topicPartition, Handler> completionHandler) { delegate.resume(topicPartition, completionHandler); return this; } /** * Resume specified partition which have been paused with pause. * @param topicPartition topic partition from which resume fetching * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer resume(io.vertx.kafka.client.common.TopicPartition topicPartition) { return resume(topicPartition, ar -> { }); } /** * Resume specified partition which have been paused with pause. * @param topicPartition topic partition from which resume fetching * @return current KafkaConsumer instance */ public Single rxResume(io.vertx.kafka.client.common.TopicPartition topicPartition) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { resume(topicPartition, fut); })); } /** * Resume specified partitions which have been paused with pause. * @param topicPartitions topic partition from which resume fetching * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer resume(Set topicPartitions, Handler> completionHandler) { delegate.resume(topicPartitions, completionHandler); return this; } /** * Resume specified partitions which have been paused with pause. * @param topicPartitions topic partition from which resume fetching * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer resume(Set topicPartitions) { return resume(topicPartitions, ar -> { }); } /** * Resume specified partitions which have been paused with pause. * @param topicPartitions topic partition from which resume fetching * @return current KafkaConsumer instance */ public Single rxResume(Set topicPartitions) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { resume(topicPartitions, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer partitionsRevokedHandler(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.rxjava.kafka.client.consumer.KafkaConsumer partitionsAssignedHandler(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.rxjava.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 * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seek(io.vertx.kafka.client.common.TopicPartition topicPartition, long offset, Handler> completionHandler) { delegate.seek(topicPartition, offset, completionHandler); 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.rxjava.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 current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seek(io.vertx.kafka.client.common.TopicPartition topicPartition, long offset) { return seek(topicPartition, offset, ar -> { }); } /** * 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.rxjava.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 current KafkaConsumer instance */ public Single rxSeek(io.vertx.kafka.client.common.TopicPartition topicPartition, long offset) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { seek(topicPartition, offset, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartition topic partition for which seek * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seekToBeginning(io.vertx.kafka.client.common.TopicPartition topicPartition, Handler> completionHandler) { delegate.seekToBeginning(topicPartition, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartition topic partition for which seek * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seekToBeginning(io.vertx.kafka.client.common.TopicPartition topicPartition) { return seekToBeginning(topicPartition, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartition topic partition for which seek * @return current KafkaConsumer instance */ public Single rxSeekToBeginning(io.vertx.kafka.client.common.TopicPartition topicPartition) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { seekToBeginning(topicPartition, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartitions topic partition for which seek * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seekToBeginning(Set topicPartitions, Handler> completionHandler) { delegate.seekToBeginning(topicPartitions, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartitions topic partition for which seek * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seekToBeginning(Set topicPartitions) { return seekToBeginning(topicPartitions, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartitions topic partition for which seek * @return current KafkaConsumer instance */ public Single rxSeekToBeginning(Set topicPartitions) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { seekToBeginning(topicPartitions, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartition topic partition for which seek * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seekToEnd(io.vertx.kafka.client.common.TopicPartition topicPartition, Handler> completionHandler) { delegate.seekToEnd(topicPartition, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartition topic partition for which seek * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seekToEnd(io.vertx.kafka.client.common.TopicPartition topicPartition) { return seekToEnd(topicPartition, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartition topic partition for which seek * @return current KafkaConsumer instance */ public Single rxSeekToEnd(io.vertx.kafka.client.common.TopicPartition topicPartition) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { seekToEnd(topicPartition, fut); })); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartitions topic partition for which seek * @param completionHandler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seekToEnd(Set topicPartitions, Handler> completionHandler) { delegate.seekToEnd(topicPartitions, completionHandler); return this; } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartitions topic partition for which seek * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer seekToEnd(Set topicPartitions) { return seekToEnd(topicPartitions, ar -> { }); } /** * 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.rxjava.kafka.client.consumer.KafkaConsumer#batchHandler} will only see messages * consistent with the new offset. * @param topicPartitions topic partition for which seek * @return current KafkaConsumer instance */ public Single rxSeekToEnd(Set topicPartitions) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { seekToEnd(topicPartitions, fut); })); } /** * Commit current offsets for all the subscribed list of topics and partition. * @param completionHandler handler called on operation completed */ public void commit(Handler> completionHandler) { delegate.commit(completionHandler); } /** * Commit current offsets for all the subscribed list of topics and partition. */ public void commit() { commit(ar -> { }); } /** * Commit current offsets for all the subscribed list of topics and partition. * @return */ public Single rxCommit() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { commit(fut); })); } /** * 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 * @param handler handler called on operation completed */ public void committed(io.vertx.kafka.client.common.TopicPartition topicPartition, Handler> handler) { delegate.committed(topicPartition, 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 */ public void committed(io.vertx.kafka.client.common.TopicPartition topicPartition) { committed(topicPartition, ar -> { }); } /** * 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 */ public Single rxCommitted(io.vertx.kafka.client.common.TopicPartition topicPartition) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { committed(topicPartition, fut); })); } /** * Get metadata about the partitions for a given topic. * @param topic topic partition for which getting partitions info * @param handler handler called on operation completed * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer partitionsFor(String topic, Handler>> handler) { delegate.partitionsFor(topic, handler); return this; } /** * Get metadata about the partitions for a given topic. * @param topic topic partition for which getting partitions info * @return current KafkaConsumer instance */ public io.vertx.rxjava.kafka.client.consumer.KafkaConsumer partitionsFor(String topic) { return partitionsFor(topic, ar -> { }); } /** * Get metadata about the partitions for a given topic. * @param topic topic partition for which getting partitions info * @return current KafkaConsumer instance */ public Single> rxPartitionsFor(String topic) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { partitionsFor(topic, fut); })); } /** * 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.rxjava.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.rxjava.kafka.client.consumer.KafkaConsumer batchHandler(Handler> handler) { delegate.batchHandler(new Handler>() { public void handle(io.vertx.kafka.client.consumer.KafkaConsumerRecords event) { handler.handle(io.vertx.rxjava.kafka.client.consumer.KafkaConsumerRecords.newInstance((io.vertx.kafka.client.consumer.KafkaConsumerRecords)event, __typeArg_0, __typeArg_1)); } }); return this; } /** * Close the consumer * @param completionHandler handler called on operation completed */ public void close(Handler> completionHandler) { delegate.close(completionHandler); } /** * Close the consumer */ public void close() { close(ar -> { }); } /** * Close the consumer * @return */ public Single rxClose() { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { close(fut); })); } /** * 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 * @param handler handler called on operation completed */ public void position(io.vertx.kafka.client.common.TopicPartition partition, Handler> handler) { delegate.position(partition, 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 */ public void position(io.vertx.kafka.client.common.TopicPartition partition) { position(partition, ar -> { }); } /** * 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 */ public Single rxPosition(io.vertx.kafka.client.common.TopicPartition partition) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { position(partition, fut); })); } /** * 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. * @param handler handler called on operation completed */ public void offsetsForTimes(io.vertx.kafka.client.common.TopicPartition topicPartition, Long timestamp, Handler> handler) { delegate.offsetsForTimes(topicPartition, timestamp, 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. */ public void offsetsForTimes(io.vertx.kafka.client.common.TopicPartition topicPartition, Long timestamp) { offsetsForTimes(topicPartition, timestamp, ar -> { }); } /** * 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 */ public Single rxOffsetsForTimes(io.vertx.kafka.client.common.TopicPartition topicPartition, Long timestamp) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { offsetsForTimes(topicPartition, timestamp, fut); })); } /** * Get the first offset for the given partitions. * @param topicPartition the partition to get the earliest offset. * @param handler handler called on operation completed. Returns the earliest available offset for the given partition */ public void beginningOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition, Handler> handler) { delegate.beginningOffsets(topicPartition, handler); } /** * Get the first offset for the given partitions. * @param topicPartition the partition to get the earliest offset. */ public void beginningOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition) { beginningOffsets(topicPartition, ar -> { }); } /** * Get the first offset for the given partitions. * @param topicPartition the partition to get the earliest offset. * @return */ public Single rxBeginningOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { beginningOffsets(topicPartition, fut); })); } /** * 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. * @param handler handler called on operation completed. The end offset for the given partition. */ public void endOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition, Handler> handler) { delegate.endOffsets(topicPartition, 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. */ public void endOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition) { endOffsets(topicPartition, ar -> { }); } /** * 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 */ public Single rxEndOffsets(io.vertx.kafka.client.common.TopicPartition topicPartition) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { endOffsets(topicPartition, fut); })); } /** * 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.rxjava.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) * @param handler handler called after the poll with batch of records (can be empty). */ public void poll(java.time.Duration timeout, Handler>> handler) { delegate.poll(timeout, new Handler>>() { public void handle(AsyncResult> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.kafka.client.consumer.KafkaConsumerRecords.newInstance((io.vertx.kafka.client.consumer.KafkaConsumerRecords)ar.result(), __typeArg_0, __typeArg_1))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); } /** * 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) */ public void poll(java.time.Duration timeout) { poll(timeout, ar -> { }); } /** * 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 */ public Single> rxPoll(java.time.Duration timeout) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { poll(timeout, fut); })); } 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; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy