2016-05-01 64 views
-1

我正在使用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沒有默認的構造函數。 有什麼想法我在這裏失蹤?

感謝 馬杜

回答

0

由於我用的是KafkaProducer API,我並不需要

partitioner.class=kafka.producer.ByteArrayPartitioner 

財產。問題是有兩個kafkaclient罐子的副本。我們已經配置了我們的安裝,以便所有庫jar文件都位於外部共享目錄中。但由於POM配置錯誤,war文件在它的lib目錄中也有一個kafka客戶端的副本。一旦我解決了這個問題,它運行良好。

Madhu

相關問題