I'm trying to build a Spring XD stream that takes a field-value-counter of a json string. Json string is sent in a message through RabbitMQ queue with header Content-Type of application/json. Spring XD logs the message(Json string) and writes it to a file but it doesn't return a field-value-counter nor shows it on the list in spring xd shell (xd:>field-value-counter list).
Here's my shell commands
stream create rabbitqueue1 --definition "rabbit | log"
stream create rabbitqueue1jsonset1 --definition "tap:stream:rabbitqueue1 > field-value-counter --fieldName=type --name=proftype" --deploy
stream create rabbitqueue1out --definition "tap:stream:rabbitqueue1 > file --binary=true --name=rabbitqueue1outfile" --deploy
stream deploy rabbitqueue1
Here's an example json string
{
"created": "2017-01-18T09:45:34.716+05:30",
"firstName": "FirstName",
"id": 1,
"lastName": "LastName",
"profileName": "Profname",
"type": "admin"
}
The question is why Spring XD stream doesn't count field values of the json string?
The FVC can only handle Tuple
or String
payloads (or a java bean).
The Rabbit source produces a byte[]
by default unless the content-type is text/plain
.
If you add --inputType=text/plain
to the field-value-counter
, the message bus will convert the byte[]
to String
.