Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A note on the subscriptionState: Its reference will be shared by both the polling and background threads.

Image Added

Important Components

Background thread and its lifecycle

...

Background thread and its lifecycle

Image Added

  1. Upon initialization of the consumer, the coordinator is down

  2. The polling thread starts the background thread; the background thread moves to the initialized state

  3. The background thread loop:

    1. Poll for the new events (for example, a commit event) from the queue, if any

    2. Check the background thread state (connected to a coordinator or not)

      1. If the event requires a coordinator.  Moves the coordinator to the discovery (coordinator discovery) state.

      2. If not, execute the event.

      3. Check the coordinator connection.  If the FindCoordinator request hasn't been completed, stay in the discovery state.  If the request fails, transition to the initialized state.  Otherwise, the coordinator is found and transition to the stable state.

  4. Poll ConsumerCoordinator

  5. Poll networkClient

  6. Go to 3

  7. If close() is received:

    1. set close to true to that the loop and exit

    2. poll coordinator and network client

    3. Commit

...