Probably I am missing a setting or two here but with KafkaListenerContainerFactory setup for ackMode as manual, I see messages are streaming through @KafkaListener method when I print them on receive. We are not acknowledging the message anywhere in the application.
Appreciate if anyone can point out where the issue is. Thanks in advance.
Using spring kafka version -- 2.3.0.RELEASE
ListenerContainerFactory
KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<GenericData.Record, GenericData.Record>>
kafkaListenerContainerFactory(
ConsumerFactory<GenericData.Record, GenericData.Record> consumerFactory) {
requireNonNull(consumerFactory, "consumerFactory must not be null");
ConcurrentKafkaListenerContainerFactory<GenericData.Record, GenericData.Record> factory =
new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactory);
factory.setBatchListener(true);
factory.setConcurrency(4);
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL);
return factory;
}
Receives the messages here
public List<InventoryRecord> onMessage(@Payload List<ConsumerRecord<byte[],
GenericArray<GenericRecord>>> consumerRecords, Acknowledgment acknowledgment) {
application.yml
kafka:
consumer:
key-deserializer: org.apache.kafka.common.serialization.ByteArrayDeserializer
value-deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
heartbeat-interval: 50000ms
client-id: card-processor-consumer
group-id: card-processor-consumer
max-poll-records: 24
properties:
basic:
auth:
credentials:
source: SASL_INHERIT
security.protocol: SASL_SSL
sasl.mechanism: SCRAM-SHA-512
sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username=zzzzzzz password=xxxxxxxxx;
request.timeout.ms: 1800000
session.timeout.ms: 360000
max.poll.interval.ms: 290000
listener:
concurrency: 4
ack-mode: manual