Class KafkaStreamConsumer<T>
java.lang.Object
com.avoka.fc.core.stream.consumer.KafkaStreamConsumer<T>
- Type Parameters:
T
- the type of data being consumed
- All Implemented Interfaces:
IStreamConsumer<T>
Represents a Kafka consumer for reading data from Kafka streams.
- Since:
- 24.4.0
-
Constructor Summary
ConstructorDescriptionKafkaStreamConsumer
(ServiceConnection serviceConnection) Constructs a KafkaStreamConsumer object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the consumer.getKafkaConsumer
(Properties properties) Retrieves a Kafka consumer instance with the provided properties.Lists the streams available for consumption.Polls data from the stream.void
shutdown()
shutdown the consumer.(This method will wake up consumer before closing)Subscribes to a single topic.Subscribes to multiple topics.void
wakeup()
Wakes up the consumer to process data.
-
Constructor Details
-
KafkaStreamConsumer
Constructs a KafkaStreamConsumer object.- Parameters:
serviceConnection
- the service connection used for Kafka setup
-
-
Method Details
-
listStreams
Lists the streams available for consumption.- Specified by:
listStreams
in interfaceIStreamConsumer<T>
- Returns:
- a list of streams
- Throws:
StreamWakeupException
- If wakeup method be called.
-
wakeup
public void wakeup()Wakes up the consumer to process data.- Specified by:
wakeup
in interfaceIStreamConsumer<T>
-
shutdown
public void shutdown()shutdown the consumer.(This method will wake up consumer before closing)- Specified by:
shutdown
in interfaceIStreamConsumer<T>
-
close
public void close()Close the consumer.- Specified by:
close
in interfaceIStreamConsumer<T>
-
poll
Polls data from the stream.- Specified by:
poll
in interfaceIStreamConsumer<T>
- Returns:
- the data polled from the stream
- Throws:
StreamWakeupException
- If wakeup method be called.
-
subscribe
Subscribes to a single topic.- Specified by:
subscribe
in interfaceIStreamConsumer<T>
- Parameters:
topic
- the topic to subscribe to- Returns:
- the stream consumer instance
-
subscribe
Subscribes to multiple topics.- Specified by:
subscribe
in interfaceIStreamConsumer<T>
- Parameters:
topics
- the list of topics to subscribe to- Returns:
- the stream consumer instance
-
getKafkaConsumer
protected org.apache.kafka.clients.consumer.Consumer<String,T> getKafkaConsumer(Properties properties) Retrieves a Kafka consumer instance with the provided properties.- Parameters:
properties
- the properties for Kafka consumer configuration- Returns:
- the Kafka consumer instance
-