liveBook · Manning

Message payload format

As explained in Microservices Patterns, Second Edition

The representation used to encode the data carried in a message’s payload.

A message payload format represents the data carried between services. Choose it with IPC efficiency, API usability, evolvability, and cross-language use in mind; some mechanisms, such as gRPC, dictate the format. section 8.1.6

Text and binary formats make different trade-offs:

  • Text formats such as JSON and XML are readable and self-describing, helping consumers select values and tolerate many schema changes. They can be verbose and costly to parse, especially for large messages. section 8.1.6
  • Binary formats such as Avro and Protocol Buffers are compact and fast to process, but require more tooling and are not human-readable. section 8.1 section 8.1.6
  • Use cross-language formats rather than language-specific serialization. JSON Schema and XML Schema can document message structure and validate messages. section 8.1.6
Table 8.3 The benefits and drawbacks of text-based vs. binary formats for message payloads

Format

Benefits

Drawbacks

Text

  • Human-readable
  • Simple to process
  • Self descriptive
  • Verbose
  • Inefficient to process large messages

Binary

  • Compact
  • Fast to process
  • Requires more tooling
  • Not human-readable

Compare the listed benefits and drawbacks of text and binary payload formats. section 8.1.6

How Microservices Patterns, Second Edition covers it

How deep it goes
Compares text and binary trade-offs and explains text schemas, but gives little detail on binary formats.
Examples
Names JSON, XML, Avro, Protocol Buffers, JSON Schema, and XML Schema.
What you can do after
Evaluate formats against efficiency, API usability, evolvability, readability, and processing trade-offs.
How it connects
Connects payload formats to interprocess communication, APIs, gRPC, JSON Schema, and XML Schema.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.