• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

AcknowledgingMessageListener vs @KafkaListener

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am working on coming up with a kafka consumer based on springboot. There is requirement to commit offset within consumer program instead of relying upon auto commit provided by kafka. So when explored on options to do this I found two ways
1. To create ConcurrentMessageListenerContainer within kafka configuration bean by passing acknowledgement mode as AckMode.MANUAL_IMMEDIATE. Pass the reference of class that implements AcknowledgingMessageListener. This will give handle to Acknowledgement object in onMessage method. In onMessage we can consume message then if no exceptions are there we can invoke acknowledge() on Acknowledgement object.
2. To create ConcurrentKafkaListenerContainerFactory within kafka configuration bean by passing acknowledgement mode as AckMode.MANUAL_IMMEDIATE. Then have @KafkaListener annotation with topics and groupid defined. listen method contains handle to Acknowledgement object and once processing of message is completed we can invoke acknowledge() on Acknowledgement object.

Want to understand the pros and cons of above two approaches. To me right now both approaches seems to be achieving same functionality, so if I am implementing kafka consumer, which approach is better to adopt.

Thanks
Kranthi
 
Destroy anything that stands in your way. Except this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic