我正在使用Kafka Broker的IBM Bluemix實現。實例化KafkaProducer時發生異常
我有以下屬性創建KafkaProducer:
key.serializer=org.apache.kafka.common.serialization.ByteArraySerializer
value.serializer=org.apache.kafka.common.serialization.ByteArraySerializer
bootstrap.servers=xxxx.xxxxxx.xxxxxx.xxxxxx.bluemix.net:xxxx
client.id=messagehub
acks=-1
security.protocol=SASL_SSL
ssl.protocol=TLSv1.2
ssl.enabled.protocols=TLSv1.2
ssl.truststore.location=xxxxxxxxxxxxxxxxx
ssl.truststore.password=xxxxxxxx
ssl.truststore.type=JKS
ssl.endpoint.identification.algorithm=HTTPS
KafkaProducer<byte[], byte[]> kafkaProducer =
new KafkaProducer<byte[], byte[]>(props);
有了這個,我有以下異常:
org.apache.kafka.common.KafkaException: org.apache.kafka。 clients.producer.internals.DefaultPartitioner不是 org.apache.kafka.clients.producer.Partitioner的一個實例
閱讀下面的博客後: http://blog.rocana.com/kafkas-defaultpartitioner-and-byte-arrays我添加下面一行到我的屬性文件,即使我使用新的API:
partitioner.class=kafka.producer.ByteArrayPartitioner
現在我得到這個異常:
org.apache .kafka.common.KafkaException:無法實例化類 kafka.producer.ByteArrayPartitioner它是否具有公共無參數 構造函數?
它看起來像ByteArrayPartitioner
沒有默認的構造函數。 有什麼想法我在這裏失蹤?
感謝 馬杜