Deal of The Day! 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

Posted by Vivan on Nov 23, 2025 at 12:04 AM

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);

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


Get Premium CCDAK Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
30 comments · newest first
CH
Charlette 6 months ago
But the order matters, right?
VA
Val 6 months ago
I feel like option A is correct.
LU
Lucia 6 months ago
The subscribe and assign methods can work together.
JU
Julie 7 months ago
Why would it throw an exception?
TI
Titus 7 months ago
Seems odd, but I guess it could work.
JE
Jeannetta 7 months ago
Wait, can you really use both subscribe() and assign() together?
KI
Kimbery 8 months ago
I think it might throw an IllegalStateException.
LY
Lynelle 8 months 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.
CA
Cassandra 8 months ago
I agree with Erin. Mixing subscribe and assign seems like a recipe for disaster. Better stick to one or the other.
ER
Erin 8 months ago
Hmm, I'm not sure about that. Isn't there a risk of some kind of conflict between the two methods?
SA
Sanda 8 months ago
The code looks good to me. Subscribe and assign should work together nicely.
AN
Antonio 8 months ago
I feel like I've seen examples where you can use both, but I can't recall the exact details. This is tricky!
JE
Jerry 9 months ago
I practiced a similar question where using subscribe() and assign() together caused issues. Maybe it's option B?
RE
Reuben 9 months ago
I'm not so sure about that. I remember something about IllegalStateException when using both methods.
ST
Staci 9 months ago
I think option A is correct because subscribe() and assign() can be used together, right?
ST
Stephania 9 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.
NU
Nu 9 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.
TO
Tonette 9 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.
CL
Claribel 10 months ago
Totally agree, that's how it works!
GR
Gracia 10 months ago
No way, IllegalStateException!
MA
Maryann 10 months ago
I think it works fine.
MA
Mabelle 10 months ago
This code subscribes to topic1 and assigns partitions 0 and 1.
JA
Jarod 10 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!
GW
Gwenn 11 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.
AS
Ashley 11 months ago
This looks straightforward. I'll just follow the code snippet and subscribe to the topic, then assign the specific partitions I need.
RE
Reuben 5 months ago
↳ replying to Ashley
I’ll try it and see what happens!
PE
Penney 5 months ago
↳ replying to Ashley
I read it throws an exception.
FR
Francis 6 months ago
↳ replying to Ashley
Are you sure about the order?
MO
Mozell 6 months ago
↳ replying to Ashley
I think it should work fine.
KA
Kasandra 6 months ago
↳ replying to Ashley
Looks good to me!
0/2000 characters

Save Cancel