nerdexam
Confluent

CCDAK · Question #147

A consumer wants to read messages from a specific partition of a topic. How can this be achieved?

The correct answer is B. Call assign() passing a Collection of TopicPartitions as the argument. assign() can be used for manual assignment of a partition to a consumer, in which case subscribe() must not be used. Assign() takes a collection of TopicPartition object as an argument

Developing Kafka Consumers

Question

A consumer wants to read messages from a specific partition of a topic. How can this be achieved?

Options

  • ACall subscribe(String topic, int partition) passing the topic and partition number as the arguments
  • BCall assign() passing a Collection of TopicPartitions as the argument
  • CCall subscribe() passing TopicPartition as the argument

How the community answered

(42 responses)
  • A
    5% (2)
  • B
    93% (39)
  • C
    2% (1)

Explanation

assign() can be used for manual assignment of a partition to a consumer, in which case subscribe() must not be used. Assign() takes a collection of TopicPartition object as an argument

Topics

#assign()#TopicPartition#manual partition assignment#consumer API

Community Discussion

No community discussion yet for this question.

Full CCDAK Practice