kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Snehalata Nagaje <snehalata.nag...@harbingergroup.com>
Subject Re: How to fetch old messages from kafka
Date Wed, 04 Feb 2015 09:29:17 GMT


Hi Mayuresh,


Thanks for quick response.

We can reset the offset and get first 10 messages, but since we need to back in reverse sequence,
suppose user has consumed messages upto 100 offset , currently there are only last 10 messages
are visible, from 100 -90, now I want to retrieve messages from 80 to 90, how can we do that?

Can we use getOffsetBefore() function to get valid offset before given time, this will return
all valid offsets. we can get all valid offsets before latest time.

Then we can fetch messages from any given valid offset returned from getOffsetBefore().

is this correct approach?

Thanks,
Snehalata

----- Original Message -----
From: gharatmayuresh15@gmail.com
To: users@kafka.apache.org
Sent: Wednesday, February 4, 2015 11:24:46 AM
Subject: Re: How to fetch old messages from kafka

In that case you will have to maintain the offsets consumed and reset the offsets in case
you need to consume from past.

For example, suppose you have a userA for which you have a partitionA for topic TopicA. Each
page shown to user increments the offset by 10. You have consumed till offset 100 and the
user wants to go back 1 page you will have to reset the offset for TopicA partitionA in the
zookeeper. Since you are using simple consumer the offset management has to be done by your
application.

Thanks,

Mayuresh

Sent from my iPhone

> On Feb 3, 2015, at 9:18 PM, Snehalata Nagaje <snehalata.nagaje@harbingergroup.com>
wrote:
> 
> 
> 
> Hi ,
> 
> 
> We are using kafka for storing messages in chat application.
> 
> Currently we divided each topic in multiple partitions. each partition stores data for
given customer who uses the application.
> 
> Right now on very first request, application fetches log from kafka from earliest valid
offset to maxiumum 100000 bytes. hence it reads all messages for given topic
> 
> for given partition. Now we want to apply pagination as linkedin, facebook does. Only
latest 10-15 messages should be displayed. And then on scroll down
> 
> fetch next set of previous messages, we are using Simple consumer to fetch messages.
> 
> Can you please guide on this?
> 
> 
> Thanks,
> Snehalata

Mime
View raw message