seek() and assign() APIs bypass consumer groups entirely.
What you’ll learn:
- When to use seek() and assign() instead of consumer groups
- How to read from a specific partition and offset
- How to implement a bounded consumer (read N messages)
- Remove the
group.idfrom the consumer properties (we don’t use consumer groups anymore). - Remove the subscription to the topic.
- Use consumer
assign()andseek()APIs.
7 of partition 0 of the topic demo_java.
Partition offset
Make sure the partition offset of partition0 of the topic demo_java is at least 7. Produce a number of messages to the topic to achieve that.
Run the application. The console of the application will display the selected messages.
Next steps
- Consumer in threads for multi-threaded consumers
- Rebalance listener for manual offset management
- Consumer concepts for foundational understanding