Hessian

This article introduces Hessian serialization

1 Introduction

Hessian serialization is a network protocol that supports dynamic typing, cross-language, and object-based transfer. The binary stream of Java object serialization can be used by other languages (such as C++, Python). Its features include:

  1. Self-describing serialization types. It does not rely on external description files or interface definitions and uses one byte to represent common basic types, significantly shortening the binary stream.
  2. Language-independent, supports scripting languages.
  3. Simple protocol, more efficient than Java native serialization.
  4. Compared to Hessian1, Hessian2 adds compressed encoding, the size of its serialized binary stream is 50% of Java serialization, serialization time is 30% of Java serialization, and deserialization time is 20% of Java serialization.

2 Usage

In the Dubbo framework, when using the Dubbo communication protocol, Hessian2 is used as the default serialization.

2.1 Configuration

  1. # application.yml (Spring Boot)
  2. dubbo:
  3. protocol:
  4. serialization: hessian2

or

  1. # dubbo.properties
  2. dubbo.protocol.serialization=hessian2
  3. # or
  4. dubbo.consumer.serialization=hessian2
  5. # or
  6. dubbo.reference.com.demo.DemoService.serialization=hessian2

or

  1. <dubbo:protocol serialization="hessian2" />
  2. <!-- or -->
  3. <dubbo:consumer serialization="hessian2" />
  4. <!-- or -->
  5. <dubbo:reference interface="xxx" serialization="hessian2" />

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)