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>>> recordOrRecordsConsumer,
long idlePingTimeout,
Consumer<? super org.apache.kafka.common.TopicPartition> idlePingConsumer) |
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>>> recordOrRecordsConsumer) |
Modifier and Type | Method and Description |
---|---|
boolean |
isRunning() |
void |
start() |
void |
stop() |
<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. |
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>>> recordOrRecordsConsumer)
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>>> recordOrRecordsConsumer, long idlePingTimeout, Consumer<? super org.apache.kafka.common.TopicPartition> idlePingConsumer)
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 start()
start
in interface ConsumerActions<K,V>
public void stop()
stop
in interface ConsumerActions<K,V>
public boolean isRunning()
isRunning
in interface ConsumerActions<K,V>
Copyright © 2019 Red Hat. All rights reserved.