What are Apache Kafka topic name limitations?

2019-03-17 05:32发布

问题:

I have just tried creating a Kafka topic "user:created" and saw this error in Kafka logs: Invalid character ':' in value part of property. I googled and found that in a mailing list people are talking about deprecating . and _ symbols too.

Which symbols can't be used in Apache Kafka topic names?

回答1:

According to source code for kafka 10

val legalChars = "[a-zA-Z0-9\\._\\-]"
private val maxNameLength = 255
private val rgx = new Regex(legalChars + "+")

So, max length is 255 symbols and letters, . (dot), _ (underscore), - (minus) can use used

In the Kafka 0.10 the maxNameLength was changed from 255 to 249. See commit

In the Kafka 0.11 class Topic was moved to internal package source