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
- Change your consume group to a brand new one with
CONSUME_FROM_LAST_OFFSET
- 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.