Karaf - Kafka OSGI bundle - Producer issue

前端 未结 3 916
臣服心动
臣服心动 2021-01-14 05:46

I am trying to create a simple bundle for Kafka producer in apache Karaf version 4.0.3 .

Here is my Java code



        
相关标签:
3条回答
  • 2021-01-14 05:55

    using Kafka client version 0.8.2.2_1, solved the issue .

    0 讨论(0)
  • 2021-01-14 05:56

    I saw this same problem in 0.9.0. It turned out that a Thread context loader was set, and in that case Kafka uses that classloader to resolve. So the thread context classloader should either be:

    • A classloader that can resolve all the Kafka related stuff
    • null

    Don't know if this is going to bite me, but adding:

    Thread.currentThread().setContextClassLoader(null);
    

    did the trick.

    0 讨论(0)
  • 2021-01-14 06:21

    Might me useful for others, work around suggested in JIRA

    props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.StringSerializer.class);
    
    props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, org.apache.kafka.common.serialization.StringSerializer.class);
    
    0 讨论(0)
提交回复
热议问题