-1

enter image description here

I changed my consume group and start to consume,it consumed from last offset as default,it is right.

But when i restart this consumer it consume the history message,why it not consume the history message for the first time startup but do for the second time.

And the offsets of brokers from 3000 to 4000.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
camus
  • 11
  • 4

1 Answers1

1

CONSUME_FROM_LAST_OFFSET only takes effect on a brand new consume group.

So for your first restart, you change your consume group(Say from CG-A to CG-B) so it is brand new consume group, then it will consume from the last offset as you expected.

For your second attempt, after offline for long, you restart your instance with the same consume grop GC-B, rocketmq will consume from the offset broker has been remembered, which is actually working by design.

So for the scenario that you want to skip the history message but only consume from the last offset, you may either

  1. Change your consume group to a brand new one with CONSUME_FROM_LAST_OFFSET
  2. Remain using your consume group but reset the consume group's consume offset to the latest offset before restarting your instance.

NOTE

If you are using broadcast consumer, whose offset is stored in local file(the fil path related to the instance name) rather than broker, please specify your instance name

consumer.setInstanceName("YOUR_INSTANCE_NAME");

. Otherwise, every time you restart, the instance name is changed(default to process id) thus consumer could not file so it may consume from the last offset every time you restart.

JaskeyLam
  • 15,405
  • 21
  • 114
  • 149
  • thank you for your answer but it did not offline, it consume all the time.真是奇怪,新的consumergroup刚启动时确实是CONSUME_FROM_LAST_OFFSET,但是重启一下就开始重复消费以前的,这之间一直在消费的 – camus Jun 16 '17 at 02:47
  • my consumer is broadcast CONSUME_FROM_LAST_OFFSET is still take effect? – camus Jun 16 '17 at 02:51
  • @camus, paste your code to your question that how you start your consumer. – JaskeyLam Jun 16 '17 at 07:50