Skip to content

Content type conversion matrix

Oleg Zhurakousky edited this page Jan 24, 2018 · 18 revisions

Introduction

This page documents the expectation one must have when producing and consuming messages via Spring Cloud Stream channel-based binders (i.e., Kafka, Rabbit)

Assumptions and expectations

  • 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)
  • 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

Supported Content-Types

Below is the list of content types supported by the provided MessageConverters

  • application/json application/octet-stream
  • application/x-java-object (must contain type attribute 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

Clone this wiki locally