If you publish messages before you start the consumer, not that consumers
by default start from the end of a queue. This is to prevent consumers from
being overwhelmed with old messages when they start. The auto.offset.reset
setting of the consumer can influence this behavior.

On Tue, Mar 29, 2016 at 6:49 AM, Ratha v <vijayara...@gmail.com> wrote:
>
> Hi all;
> I use kafka 0.9.0.1.
> I publish 10 messages to my kafka server, but when i try to use my
> consumer, it does not retriev any messages.
> In the following code snippet, it prints 111 and 222 and thread runs
> forever without sending any records :(
>
> I set consumer.timeout property, but nothing helps me..
>
> Can anybody help me?
>
> public void run() {
>
> try {
>
> consumer.subscribe(topics);
>
> System.out.println("111");
>
> while (true) {
>
> System.out.println("2222");
>
> ConsumerRecords<String, RawFile> records = consumer.poll(100);
>
> System.out.println("3333 : "+records.count());
>
> for (ConsumerRecord<String, RawFile> record : records) {
>
> System.out.println("4444");
>
> FileProcessor processor = new FileProcessor();
>
> processor.processFile(record.value());
>
>
> }
>
> }
>
>
> } catch (Throwable e) {
>
> e.printStackTrace();
>
> System.out.println("eror in polling");
>
>
> } finally {
>
> consumer.close();
>
> }
>
> }
> --
> -Ratha
> http://vvratha.blogspot.com/




--
Cees de Groot
Principal Software Engineer
PagerDuty, Inc.

Reply via email to