spring-xd kafka sink(file)写ascii代码

rep*_*ion 1 apache-kafka spring-xd

我正在用spring-xd测试apache-kafka.

我正在关注这个例子.http://spring.io/blog/2015/04/15/using-apache-kafka-for-integration-and-data-processing-pipelines-with-spring

它工作正常,我正在使用spring-xd.

xd> stream create kafka-source-test --definition "kafka --zkconnect=localhost:2181 --topic=event-stream | log" --deploy
Run Code Online (Sandbox Code Playgroud)

我将json字符串发送到kafka.

{ "名": "tester1", "年龄": "0"}

它有效,但日志是

INFO dispatcher-1 sink.kafka-source-test - [B@2907e63b
Run Code Online (Sandbox Code Playgroud)

所以我试着下沉.文件

xd> stream create kafka-source-test --definition "kafka --zkconnect=localhost:2181 --topic=event-stream | file" --deploy
Run Code Online (Sandbox Code Playgroud)

并检查出文件我遇到了这个ascii代码

123,34,110,97,109,101,34,58,34,116,101,115,116,101,114,50,34,44,34,97,103,101,34,58,49,125

这意味着这个json字符串.

{ "名": "tester1", "年龄": "0"}

如何使用json String获取msg?帮我!

小智 5

使用--outputType = text/plain或--outputType = application/json.其中任何一个应该工作.它应作为参数传递给流定义中的kafka源.