我正在使用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
没有默认的构造函数。 有什么想法我在这里失踪?
感谢 马杜