You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Asiri Liyana Arachchi <as...@gmail.com> on 2017/06/24 02:54:44 UTC

Using camel how to get the last message with the latest offset

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

Re: Using camel how to get the last message with the latest offset

Posted by Asiri Liyana Arachchi <as...@gmail.com>.
Hi all,

Relating to same issue.

Stackoverflow link: https://stackoverflow.com/questions/44745203/camel-kafka-whats-meant-by-maxpollrecords-configuration <https://stackoverflow.com/questions/44745203/camel-kafka-whats-meant-by-maxpollrecords-configuration>

> On Jun 24, 2017, at 10:54 AM, Asiri Liyana Arachchi <asiriwork@GMAIL.COM <ma...@GMAIL.COM>> wrote:
> 
> 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