what is the property to accept binary json message in spring-cloud-stream kafka binder

守給你的承諾、 提交于 2019-12-23 02:17:33

问题


I am using spring-cloud-stream kafka binder to consume messages from a kafka topic. The source system is sending the json message in ascii. When My consumer listens to the topic it throws

o.s.c.s.b.k.KafkaMessageChannelBinder    : Could not convert message: 7B22736..

Is there any property that I can set in my .yml file to deserialize it? or is there an example that I can look into?


回答1:


I am not sure what you mean by json in hexadecimal-binary data if you mean it's ascii data in a byte[], try adding spring.cloud.stream.bindings.input.content-type=text/plain (or application/json).




回答2:


You can look for the configuration property here: http://docs.spring.io/spring-cloud-stream/docs/Brooklyn.SR2/reference/htmlsingle/#_kafka_consumer_properties

In your case, you can set this by doing the following:

spring.cloud.stream.kafka.bindings.<channelName>.consumer.configuration.value.deserializer=<Deserialzier class>

Kafka binder takes all properties from the configuration map. Thus you can use any generic Kafka consumer properties and pass them this way.




回答3:


When I added content-type:plain/text and spring.cloud.stream.bindings.<subscriptionChannel>.consumer.‌​headerMode:raw it worked.

Thank you!



来源:https://stackoverflow.com/questions/42653913/what-is-the-property-to-accept-binary-json-message-in-spring-cloud-stream-kafka

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!