You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Kevin Sjöberg <ke...@fortnox.se> on 2015/06/02 18:25:37 UTC

Using SimpleConsumer to get messages from offset until now

Hello,

I'm trying to create a custom consumer that given a offset returns all
messages until now. After this is done, the consumer is not needed anymore,
hence, the consumer does not have to continue consuming messages that are
being produced.

The Kafka cluster exists of one broker and we only use one partition as
well. My understanding is that I can use the SimpleConsumer API for this,
but I'm a bit unsure on how to go about it.

Would anyone mind helping me out or point me in the right direction?

Cheers,
Kevin

-- 
Kevin Sjöberg

-- 
Du skapar din faktura, vi skickar den och ser till att kunden betalar. Vi 
sköter allt, hela vägen tills fakturan är betald! 
Läs om Nox Finans här 
<https://www.fortnox.se/nox/?utm_source=signature&utm_medium=email&utm_campaign=noxfinans&utm_term=fakturahantering>
.

Re: Using SimpleConsumer to get messages from offset until now

Posted by Kevin Sjöberg <ke...@fortnox.se>.
Thank you! I will definitely look into that example.

2015-06-03 4:27 GMT+02:00 luo.fucong <ba...@gmail.com>:

> I think the SimpleConsumer Example(
> https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example
> <
> https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example>)
> in the wiki is a very good starting point.
>
> You can pass in the offset to the FetchRequest. And you can ask for the
> latest offset using kafka.api.OffsetRequest.LatestTime()
>
> > 在 2015年6月3日,上午12:25,Kevin Sjöberg <ke...@fortnox.se> 写道:
> >
> > Hello,
> >
> > I'm trying to create a custom consumer that given a offset returns all
> > messages until now. After this is done, the consumer is not needed
> anymore,
> > hence, the consumer does not have to continue consuming messages that are
> > being produced.
> >
> > The Kafka cluster exists of one broker and we only use one partition as
> > well. My understanding is that I can use the SimpleConsumer API for this,
> > but I'm a bit unsure on how to go about it.
> >
> > Would anyone mind helping me out or point me in the right direction?
> >
> > Cheers,
> > Kevin
> >
> > --
> > Kevin Sjöberg
> >
> > --
> > Du skapar din faktura, vi skickar den och ser till att kunden betalar. Vi
> > sköter allt, hela vägen tills fakturan är betald!
> > Läs om Nox Finans här
> > <
> https://www.fortnox.se/nox/?utm_source=signature&utm_medium=email&utm_campaign=noxfinans&utm_term=fakturahantering
> >
> > .
>
>


-- 
Kevin Sjöberg

-- 
Du skapar din faktura, vi skickar den och ser till att kunden betalar. Vi 
sköter allt, hela vägen tills fakturan är betald! 
Läs om Nox Finans här 
<https://www.fortnox.se/nox/?utm_source=signature&utm_medium=email&utm_campaign=noxfinans&utm_term=fakturahantering>
.

Re: Using SimpleConsumer to get messages from offset until now

Posted by "luo.fucong" <ba...@gmail.com>.
I think the SimpleConsumer Example(https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example <https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example>) in the wiki is a very good starting point.

You can pass in the offset to the FetchRequest. And you can ask for the latest offset using kafka.api.OffsetRequest.LatestTime()

> 在 2015年6月3日,上午12:25,Kevin Sjöberg <ke...@fortnox.se> 写道:
> 
> Hello,
> 
> I'm trying to create a custom consumer that given a offset returns all
> messages until now. After this is done, the consumer is not needed anymore,
> hence, the consumer does not have to continue consuming messages that are
> being produced.
> 
> The Kafka cluster exists of one broker and we only use one partition as
> well. My understanding is that I can use the SimpleConsumer API for this,
> but I'm a bit unsure on how to go about it.
> 
> Would anyone mind helping me out or point me in the right direction?
> 
> Cheers,
> Kevin
> 
> -- 
> Kevin Sjöberg
> 
> -- 
> Du skapar din faktura, vi skickar den och ser till att kunden betalar. Vi 
> sköter allt, hela vägen tills fakturan är betald! 
> Läs om Nox Finans här 
> <https://www.fortnox.se/nox/?utm_source=signature&utm_medium=email&utm_campaign=noxfinans&utm_term=fakturahantering>
> .