Consumer<K, V> (Interface)

Package: io.axual.client.consumer

The axualClient.buildConsumer() call returns an implementation of Consumer interface.

AxualClient client = ... (1)

ConsumerConfig consumerConfig = ConsumerConfig.builder()
	.setSslConfig(...) (2)
	.build(); (3)

Processor<K, V> processor = ... (4)

Consumer<K, V> consumer = client.buildConsumer(consumerConfig); (5)

consumer.startConsuming(...); (6)
1 Build an AxualClient object.
2 Build an SslConfig object.
3 Build a ConsumerConfig object.
4 Build a Processor object.
5 Build a Consumer object.
6 Start consuming


Future<ConsumeFailedException> startConsuming()

Start consuming process. Returns a Future object wrapping a ConsumeFailedException

ConsumeFailedException stopConsuming()

Stop consuming and disconnect.

boolean isConsuming()

Indicates whether the consumer is still consuming, might return ConsumeFailedException if no longer consuming because of an error.

void close()

Closes the consumer.

ConsumerMessage<K, V> (Interface)

A wrapper for the consumed message passed to the Processor. Includes metadata information like partition, offset and timestamp.

Processor<K, V> (Interface)

Implement this interface to process each consumed message.

class MyProcessor implements Processor<K, V> {
    public void processMessage(ConsumerMessage<K, V> message) {"Processing message: Key: {}, Value: {}", message.getKey(), message.getValue());

If using Java 8, above code can be simplified using Streams API as below:

Processor<K, V> processor = message ->"Processing message: Key: {}, Value: {}", message.getKey(), message.getValue());


An Enum used used to manage consumer behavior.


This strategy will try to deliver messages once (or less) and continue processing in all failure cases. In case something fails the message will be lost. For Consumers this means skipping to the end of a new PartitionOffset upon subscribing.


This strategy will retry to deliver messages upon technical failures, potentially leading to message duplication in certain situations. Duplication is considered to be a lesser evil by applications that adopt this strategy. Be sure to be idempotent in your application when adopting this strategy. For Consumers this strategy jumps to the beginning of the stream if the consumer’s group id did not commit any offset beforehand.