title: How set protobuf param for spring kafka?
body: <p>Question: <a href="https://github.com/spring-projects/spring-kafka/issues/727" rel="nofollow noreferrer">https://github.com/spring-projects/spring-kafka/issues/727</a></p>
  
  <p>please read above link, thanks!!!</p>
  
  <p>When I use spring-boot and spring-kafka, and my code like the follow:</p>
  
  <pre><code># application.properties
  spring.kafka.bootstrap-servers=localhost:9092
  spring.kafka.consumer.group-id=mock-test
  spring.kafka.consumer.key- deserializer=org.apache.kafka.common.serialization.StringDeserializer
  # HERE: how should I set value serializer for proto message???
  spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.BytesDeserializer
  spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
  spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.BytesSerializer
  </code></pre>
  
  <p>And my Kafka producer code like the follow:</p>
  
  <pre><code>@Component
  public class Sender {
      @Autowired
      private KafkaTemplate&lt;Object, MockEvent&gt; kafkaTemplate;
  
      public void send(MockEvent events) {
          kafkaTemplate.send(Kafka.TOPIC, events);
      }
  }
  </code></pre>
  
  <p><code>MockEvent</code> is a protobuf message.</p>
  
  <p>when <code>mvn compile</code> is OK, but when run it will error: </p>
  
  <pre><code>2018-07-06 15:52:24.334  INFO 79274 --- [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser     : Kafka version : 1.0.1
  2018-07-06 15:52:24.334  INFO 79274 --- [nio-8080-exec-1] o.a.kafka.common.utils.AppInfoParser     : Kafka commitId : c0518aa65f25317e
  org.apache.kafka.common.errors.SerializationException: Can't convert value of class com.mock.event.MockEvent to class 
  org.apache.kafka.common.serialization.BytesSerializer specified in value.serializer
  Caused by: java.lang.ClassCastException: com.mock.event.MockEvent cannot be cast to org.apache.kafka.common.utils.Bytes
          at org.apache.kafka.common.serialization.BytesSerializer.serialize(BytesSerializer.java:23)
          at org.apache.kafka.common.serialization.ExtendedSerializer$Wrapper.serialize(ExtendedSerializer.java:65)
          at org.apache.kafka.common.serialization.ExtendedSerializer$Wrapper.serialize(ExtendedSerializer.java:55)
          at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:791)
          at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:768)
          at org.springframework.kafka.core.DefaultKafkaProducerFactory$CloseSafeProducer.send(DefaultKafkaProducerFactory.java:285)
          at org.springframework.kafka.core.KafkaTemplate.doSend(KafkaTemplate.java:349)
          at org.springframework.kafka.core.KafkaTemplate.send(KafkaTemplate.java:182)
  </code></pre>
  
  <p>Thanks a lot, because I want to send one proto message.</p>