-
Notifications
You must be signed in to change notification settings - Fork 631
Content type conversion matrix
Oleg Zhurakousky edited this page Jan 24, 2018
·
18 revisions
This page documents the expectation one must have when producing and consuming messages via Spring Cloud Stream channel-based binders (i.e., Kafka, Rabbit)
- The payloads of messages "on-the-wire" is represented as
byte[]while "in-binder/in-jvm" it could be anything.-
toMessage(..) ->
byte[] -
fromMessage(..) ->
<?>(specific to the nature of given MessageConverter)
-
toMessage(..) ->
- Binders perform serialization (producer) and deserialization (consumer) of payload from/to
byte[]utilizing MessageConverters. - Default content type is application/json
- Content Type can be set on channel or as Message header
- Content Type set as Message header takes precedence over content type set on channel
Below is the list of content types supported by the provided MessageConverters
- application/json application/octet-stream
-
application/x-java-object (must contain
typeattribute with FQN of the actual type:application/x-java-object; type=foo.bar.MyClass) - DEPRECATED - application/x-java-serialized-object - DEPRECATED
- application/x-spring-tuple - DEPRECATED
| Inbound content-type | Supported Handler payload type | Outbound content-type |
|---|---|---|
| - | byte[], String, POJO (json friendly) | application/json |
| application/json | byte[], String, POJO (json friendly) | application/json |
| text/* | byte[], String | text/* . |
| application/x-java-object | byte[], POJO (Kryo) | text/* . |
| application/x-java-serialized-object | byte[], POJO | application/x-java-serialized-object |
| application/octet-stream | byte[] | application/octet-stream |