K
- the type of keys in consumed messagesV
- the type of values in consumed messagespublic class ConsumerContainer<K,V> extends Object implements ConsumerActions<K,V>
submit(Function)
actions
from other threads to be executed asynchronously in the single consumer thread.Modifier and Type | Class and Description |
---|---|
static class |
ConsumerContainer.DynamicPool<K,V>
A dynamic pool of
ConsumerContainer s (typically configured with the same group.id)
sized dynamically by ConsumerContainer.DynamicPool.setConsumerThreads(int) |
ConsumerActions.DynamicAssignment<K,V>
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_CONSUMER_POLL_TIMEOUT |
Constructor and Description |
---|
ConsumerContainer(Properties consumerProperties,
org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer,
org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer,
long consumerPollTimeout,
Oneof2<Consumer<? super org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>,Consumer<? super org.apache.kafka.clients.consumer.ConsumerRecords<K,V>>> recordOrRecordsHandler,
BiConsumer<? super org.apache.kafka.clients.consumer.Consumer<?,?>,? super RuntimeException> consumerExceptionHandler,
long idlePingTimeout,
Consumer<? super org.apache.kafka.common.TopicPartition> idlePingHandler) |
ConsumerContainer(Properties consumerProperties,
org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer,
org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer,
Oneof2<Consumer<? super org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>,Consumer<? super org.apache.kafka.clients.consumer.ConsumerRecords<K,V>>> recordOrRecordsHandler,
BiConsumer<? super org.apache.kafka.clients.consumer.Consumer<?,?>,? super RuntimeException> consumerExceptionHandler) |
Modifier and Type | Method and Description |
---|---|
void |
close()
AutoCloseable
|
<R> CompletableFuture<R> |
submit(Function<? super org.apache.kafka.clients.consumer.Consumer<K,V>,? extends R> consumerAction)
Submit an action to be performed in the consumer thread and return a
CompletableFuture
that will be completed with the action outcome when executed. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isRunning, start, stop
public ConsumerContainer(Properties consumerProperties, org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer, org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer, Oneof2<Consumer<? super org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>,Consumer<? super org.apache.kafka.clients.consumer.ConsumerRecords<K,V>>> recordOrRecordsHandler, BiConsumer<? super org.apache.kafka.clients.consumer.Consumer<?,?>,? super RuntimeException> consumerExceptionHandler)
public ConsumerContainer(Properties consumerProperties, org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer, org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer, long consumerPollTimeout, Oneof2<Consumer<? super org.apache.kafka.clients.consumer.ConsumerRecord<K,V>>,Consumer<? super org.apache.kafka.clients.consumer.ConsumerRecords<K,V>>> recordOrRecordsHandler, BiConsumer<? super org.apache.kafka.clients.consumer.Consumer<?,?>,? super RuntimeException> consumerExceptionHandler, long idlePingTimeout, Consumer<? super org.apache.kafka.common.TopicPartition> idlePingHandler)
public final <R> CompletableFuture<R> submit(Function<? super org.apache.kafka.clients.consumer.Consumer<K,V>,? extends R> consumerAction)
ConsumerActions
CompletableFuture
that will be completed with the action outcome when executed.submit
in interface ConsumerActions<K,V>
R
- the return type of the actionconsumerAction
- the action to perform in the consumer thread, taking the Consumer
parameter
and returning some arbitrary resultCompletableFuture
completed with action result in consumer threadpublic void close()
close
in interface AutoCloseable
Copyright © 2020 Red Hat. All rights reserved.