K
- the class of the records keyV
- the class of the records valuepublic class KafkaConsumerImpl<K,V> extends Object implements IKafkaContinuousConsumer
Constructor and Description |
---|
KafkaConsumerImpl(Properties props,
String[] topics,
int partitionNumber,
KafkaContinuousConsumerBuilder.START_OFFSET_STRATEGY startOffsetStrategy,
long startupOffset,
long fromTimestamp,
Long offsetWatchDogTimeout,
boolean continueWhenNoRecords,
org.thales.punch.platform.api.pojo.JavaStoreSecurity securityStores)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this consumer
|
void |
commit()
Commit all the offsets for all the partitions managed by your reader.
|
int |
nextMessages(Duration timeout)
Fetch incoming messages, if any.
|
KafkaConsumerImpl<K,V> |
setMetricContext(org.thales.punch.libraries.metrics.api.IMetricContext metricContext)
Provide a metric context to this consumer
|
KafkaConsumerImpl<K,V> |
setOffsetTree(boolean useOffsetTree)
Request an offset tree t=strategy.
|
KafkaConsumerImpl<K,V> |
setReceiver(IRecordHandler<K,V> receiver)
PSet the receiver to handle incoming records.
|
KafkaConsumerImpl<K,V> |
setSmartFailureHandling(boolean smartFailureHandling)
Set the smart failure handling.
|
KafkaConsumerImpl<K,V> |
setTickInterval(long tickInterval)
Set the tick interval.
|
public KafkaConsumerImpl(Properties props, String[] topics, int partitionNumber, KafkaContinuousConsumerBuilder.START_OFFSET_STRATEGY startOffsetStrategy, long startupOffset, long fromTimestamp, Long offsetWatchDogTimeout, boolean continueWhenNoRecords, org.thales.punch.platform.api.pojo.JavaStoreSecurity securityStores)
props
- the propertiestopics
- the topicspartitionNumber
- -1 to read all partitions, gte 0 to read a given partitionstartOffsetStrategy
- one of EARLIEST, LATEST, LAST_COMMITTED or FROM_OFFSETstartupOffset
- only relevant with the FROM_OFFSET strategy. Indicates the offset to start with.fromTimestamp
- only relevant with the FROM_TIMESTAMP strategy. Indicates the timestamp to begin with.offsetWatchDogTimeout
- continueWhenNoRecords
- only relevant with the FROM_DATETIME strategy. Indicates whether to throw an error
or to continue to initialize partitions when no records are found for the given datetimesecurityStores
- the Object containing the truststore and keystore information. If not null, activate ssl.public KafkaConsumerImpl<K,V> setReceiver(IRecordHandler<K,V> receiver)
receiver
- your receiverpublic KafkaConsumerImpl<K,V> setMetricContext(org.thales.punch.libraries.metrics.api.IMetricContext metricContext)
metricContext
- your metric contextpublic KafkaConsumerImpl<K,V> setOffsetTree(boolean useOffsetTree)
useOffsetTree
- true or falsepublic KafkaConsumerImpl<K,V> setSmartFailureHandling(boolean smartFailureHandling)
smartFailureHandling
- public KafkaConsumerImpl<K,V> setTickInterval(long tickInterval)
tickInterval
- public void close()
IKafkaContinuousConsumer
close
in interface IKafkaContinuousConsumer
public int nextMessages(Duration timeout)
IKafkaContinuousConsumer
This method is blocking. It encapsulate a call to the underlying KafkaConsumer poll.
If some records are
fetched from your topic. It will invoke your IRecordHandler
in a reentrant manner.
nextMessages
in interface IKafkaContinuousConsumer
timeout
- the blocking timeout in millisecondspublic void commit()
IKafkaContinuousConsumer
IPartition
interface instead.commit
in interface IKafkaContinuousConsumer
Copyright © 2014–2023. All rights reserved.