Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how do I configure the offset? #11

Closed
xelax opened this issue Jul 30, 2014 · 4 comments
Closed

how do I configure the offset? #11

xelax opened this issue Jul 30, 2014 · 4 comments

Comments

@xelax
Copy link

xelax commented Jul 30, 2014

How do I tell the consumer whether to start from the oldest available message or from the newest available offset?

@sclasen
Copy link
Owner

sclasen commented Jul 30, 2014

hi @xelax, so the default for kafka consumers for auto.offset.reset is largest , which is how the akka-kafka consumer behaves.

to override this behavior you can add this to your application.conf used to configure the actor system you use with your AkkaConsumer

kafka.consumer.auto.offset.reset = "smallest"

@xelax
Copy link
Author

xelax commented Jul 30, 2014

Thanks for the quick answer!
I noticed that zookeeper it will remember the offset for my consumer group, so the setting operates only when there is no offset stored in zookeper for my consumer group. How do I "re-start", meaning, tell kafka to ignore the stored offset and start anew from the newest message? It would be useful, particularly for testing purpose.

@sclasen
Copy link
Owner

sclasen commented Jul 30, 2014

So the way kafka's console consumer works is that if you do --from-beginning it will just delete the consumer offsets from zookeeper before starting.

https:/apache/kafka/blob/0.8.1/core/src/main/scala/kafka/consumer/ConsoleConsumer.scala#L181

So for testing you can do similar in a before method, like

val props:AkkaConsumerProps =  //your consumer props
ZkUtils.maybeDeletePath(props.zkConnect , "/consumers/" + props.group)

@sclasen
Copy link
Owner

sclasen commented Jul 30, 2014

also ZkUtils is kafka.utils.ZkUtils which should already be on your classpath if akka-kafka is

@xelax xelax closed this as completed Jul 31, 2014
@mjuchli mjuchli mentioned this issue Sep 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants