Hi all,

When setting seekTo in configuration to "end" and then calling the 
consumer.receive, it will output null because consumer already starting from 
the end. I want to get the last message. Can that be done using camel? 

import org.apache.camel.ConsumerTemplate;
   import org.apache.camel.Exchange;
   import org.apache.camel.component.kafka.KafkaEndpoint;
   import org.springframework.beans.factory.annotation.Autowired;

   public class StackOverflow {

      @Autowired
      ConsumerTemplate kafkaConsumer;

     public void getLatestMsg() {
       KafkaEndpoint kafkaEndpoint = new KafkaEndpoint();
       kafkaEndpoint.getConfiguration().setBrokers("localhost:9092");
       kafkaEndpoint.getConfiguration().setGroupId("AsiriGroup");
       kafkaEndpoint.getConfiguration().setTopic("test");
       Exchange temp = kafkaConsumer.receive(kafkaEndpoint, 12_000);
     }
  }


Stackoverflow link : 
https://stackoverflow.com/questions/44732041/using-camel-how-to-get-the-last-message-with-the-latest-offset
 
<https://stackoverflow.com/questions/44732041/using-camel-how-to-get-the-last-message-with-the-latest-offset>



Thanks & Regards,
Asiri

Reply via email to