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

# application.yml (Spring Boot)
dubbo:
 protocol:
   serialization: hessian2

or

# dubbo.properties
dubbo.protocol.serialization=hessian2

# or
dubbo.consumer.serialization=hessian2

# or
dubbo.reference.com.demo.DemoService.serialization=hessian2

or

<dubbo:protocol serialization="hessian2" />

        <!-- or -->
<dubbo:consumer serialization="hessian2" />

        <!-- or -->
<dubbo:reference interface="xxx" serialization="hessian2" />
Last modified September 30, 2024: Translate (22d3d83a3b)