Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Running a Single Consumer

Sumit Rawal answered on June 1, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • Consumer Configuration
  • Single Consumer
  • Consumer Configurations

  • Running a Single Consumer

    0

    In this lesson, we'll learn how to run a single Kafka consumer without being a member of a consumer group.

    So far, we have seen Kafka consumers run as part of a consumer group that automatically handles rebalances and assignment of partitions. However, there may be scenarios where you want to run a single consumer that reads records from all or just a few of the partitions of a topic. In this case, there’s no need for a consumer group or rebalancing. It is sufficient for a single consumer to start consuming from the topic partitions and commit offsets as it deems fit.

    The code widget below demonstrates how to implement a single consumer. Note that in the properties we still specify the property group.id, as it is a mandatory property even though the consumer group will consist of a single consumer. Also, note we don’t use the subscribe API on the consumer object. Rather, we use the assign API to read all the partitions of the topic. Go through the comments in the listing below to understand the changes we just discussed.

    Popularity 1/10 Helpfulness 1/10 Language java
    Source: Grepper
    Tags: consumer java
    Link to this answer
    Share Copy Link
    Contributed on Jun 01 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.