The goal is to read data emitted over the network.
On the data generation side I have an app which spews to stdout. The content of this data is a JSON string.
Here's what I'm doing (on Linux Mint 17, using an BSD flavored netcat):
my_app_which_outputs_json | netcat localhost 9999
<em>In SpringXD:</em> (with
xd:>stream create --name tcptest --definition "tcp --decoder=LF --port=9999 | file " --deploy Created and deployed new stream 'tcptest'
/tmp/xd/output$ cat tcptest.out 82,117,110, ... (etc, lots more bytes)
I'm sure this is user error, but not sure what to change to make it right.
I should note that if I do this, it works as expected:
my_app_which_outputs_json > /tmp/somefile.txt ... xd:>stream create --name filetest --definition "tail --name=/tmp/somefile.txt | file" --deployAnswer1:
Following up to your own answer, the converters are currently not configured to understand that a
byte can be converted to a String with content type
Of course, even if we configured it to do so, it wouldn't be able to determine if the content really is JSON.Answer2:
I added the following to my stream defn and it is now doing what I expected. I found this in the "Type Conversion" section of the documentation.
stream create --name tcptest \ --definition "tcp --decoder=LF --port=9999 --outputType=text/plain \ | file " --deploy
(The newlines and backwhacks are not in my actual code, but are used for readability.)
I also tried
... --outputType=application/json... which did not work. Not entirely sure why.
text/plain with a byte payload activates a ByteArrayToStringMessageConverter. application/json does not currently. I have created <a href="https://jira.spring.io/browse/XD-2512" rel="nofollow">https://jira.spring.io/browse/XD-2512</a> to address this