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

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
Charlette
24 hours ago
But the order matters, right?
upvoted 0 times
...
Val
6 days ago
I feel like option A is correct.
upvoted 0 times
...
Lucia
11 days ago
The subscribe and assign methods can work together.
upvoted 0 times
...
Julie
16 days ago
Why would it throw an exception?
upvoted 0 times
...
Titus
22 days ago
Seems odd, but I guess it could work.
upvoted 0 times
...
Jeannetta
27 days ago
Wait, can you really use both subscribe() and assign() together?
upvoted 0 times
...
Kimbery
2 months ago
I think it might throw an IllegalStateException.
upvoted 0 times
...
Lynelle
2 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.
upvoted 0 times
...
Cassandra
2 months 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
2 months 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
2 months ago
The code looks good to me. Subscribe and assign should work together nicely.
upvoted 0 times
...
Antonio
2 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!
upvoted 0 times
...
Jerry
3 months ago
I practiced a similar question where using subscribe() and assign() together caused issues. Maybe it's option B?
upvoted 0 times
...
Reuben
3 months ago
I'm not so sure about that. I remember something about IllegalStateException when using both methods.
upvoted 0 times
...
Staci
3 months ago
I think option A is correct because subscribe() and assign() can be used together, right?
upvoted 0 times
...
Stephania
3 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
3 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
3 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
4 months ago
Totally agree, that's how it works!
upvoted 0 times
...
Gracia
4 months ago
No way, IllegalStateException!
upvoted 0 times
...
Maryann
4 months ago
I think it works fine.
upvoted 0 times
...
Mabelle
4 months ago
This code subscribes to topic1 and assigns partitions 0 and 1.
upvoted 0 times
...
Jarod
4 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
5 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
5 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