Misleading error message in `NotSubscribedException`
danielleontiev opened this issue · 1 comments
danielleontiev commented
The message says "consumer is not subscribed to any topics"
. Also, in javadoc comments in KafkaConsume.scala
it's mentioned multiple times that
* @note you have to first use `subscribe` to subscribe the consumer
* before using this `Stream`. If you forgot to subscribe, there
* will be a [[NotSubscribedException]] raised in the `Stream`.
But it's not completely correct. To avoid the exception you could either subscribe
to the topic or assign
partitions manually. For example, underlying org.apache.kafka.clients.consumer.KafkaConsumer
uses the following error message inside its poll
method:
throw new IllegalStateException("Consumer is not subscribed to any topics or assigned any partitions")