New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Confluent CCDAK Exam - Topic 6 Question 85 Discussion

Actual exam question for Confluent's CCDAK exam
Question #: 85
Topic #: 6
[All CCDAK Questions]

A consumer wants to read messages from partitions 0 and 1 of a topic topic1. Code snippet is shown below.

consumer.subscribe(Arrays.asList("topic1"));

List pc = new ArrayList<>();

pc.add(new PartitionTopic("topic1", 0));

pc.add(new PartitionTopic("topic1", 1));

consumer.assign(pc);

Show Suggested Answer Hide Answer
Suggested Answer: B

subscribe() and assign() cannot be called by the same consumer, subscribe() is used to leverage the consumer group mechanism, while assign() is used to manually control partition assignment and reads assignment


Contribute your Thoughts:

0/2000 characters
Kimbery
9 hours ago
I think it might throw an IllegalStateException.
upvoted 0 times
...
Lynelle
6 days ago
Option B all the way! Subscribing and assigning partitions? That's like trying to drive with one foot on the gas and the other on the brake.
upvoted 0 times
...
Cassandra
11 days ago
I agree with Erin. Mixing subscribe and assign seems like a recipe for disaster. Better stick to one or the other.
upvoted 0 times
...
Erin
16 days ago
Hmm, I'm not sure about that. Isn't there a risk of some kind of conflict between the two methods?
upvoted 0 times
...
Sanda
21 days ago
The code looks good to me. Subscribe and assign should work together nicely.
upvoted 0 times
...
Antonio
26 days ago
I feel like I've seen examples where you can use both, but I can't recall the exact details. This is tricky!
upvoted 0 times
...
Jerry
1 month ago
I practiced a similar question where using subscribe() and assign() together caused issues. Maybe it's option B?
upvoted 0 times
...
Reuben
1 month ago
I'm not so sure about that. I remember something about IllegalStateException when using both methods.
upvoted 0 times
...
Staci
1 month ago
I think option A is correct because subscribe() and assign() can be used together, right?
upvoted 0 times
...
Stephania
2 months ago
Okay, I think I've got it. The subscribe() method is the way to go here, as it will automatically assign the partitions for me. I'll just stick with that and not worry about the assign() method.
upvoted 0 times
...
Nu
2 months ago
Ah, this is a tricky one. I'm guessing the code snippet will throw an IllegalStateException, since you can't use both subscribe() and assign() methods together. I'll need to choose one or the other approach.
upvoted 0 times
...
Tonette
2 months ago
Aha, I think I see the issue here. The subscribe() method is for subscribing to the topic, while the assign() method is for manually assigning partitions. I'll need to be careful to use the right method for the right purpose.
upvoted 0 times
...
Claribel
2 months ago
Totally agree, that's how it works!
upvoted 0 times
...
Gracia
2 months ago
No way, IllegalStateException!
upvoted 0 times
...
Maryann
2 months ago
I think it works fine.
upvoted 0 times
...
Mabelle
3 months ago
This code subscribes to topic1 and assigns partitions 0 and 1.
upvoted 0 times
...
Jarod
3 months ago
Haha, this question is a real brain-teaser. I'm going to go with option B just to be safe. Can't risk an IllegalStateException on the exam!
upvoted 0 times
...
Gwenn
3 months ago
Hmm, I'm a bit unsure about this one. Doesn't the subscribe() method already assign the partitions? I'll need to double-check the Kafka documentation to make sure I'm not missing something.
upvoted 0 times
...
Ashley
3 months ago
This looks straightforward. I'll just follow the code snippet and subscribe to the topic, then assign the specific partitions I need.
upvoted 0 times
...

Save Cancel