我正在使用 Kafka Broker 的 IBM Bluemix 实现。
我正在创建具有以下属性的 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
没有默认构造函数。知道我在这里缺少什么吗?
谢谢马杜