Hessian Protocol

Hessian Protocol

Feature Description

The Hessian protocol is used for integrating services that utilize Hessian. It is based on HTTP communication and uses Servlet to expose services, with Dubbo embedding Jetty as the server implementation by default.

Hessian is an open-source RPC framework from Caucho, whose communication efficiency is higher than that of WebService and Java’s built-in serialization.

  • Number of connections: multiple connections
  • Connection method: short connection
  • Transport protocol: HTTP
  • Transport method: synchronous transmission
  • Serialization: Hessian binary serialization
  • Applicable scope: larger incoming and outgoing parameter data packets, more providers than consumers, higher pressure on providers, allows file transfer.
  • Applicable scenarios: page transfer, file transfer, or interoperability with native Hessian services.

Dubbo’s Hessian protocol can interoperate with native Hessian services, which means:

  • Providers expose services using Dubbo’s Hessian protocol, and consumers can directly call it using the standard Hessian interface,
  • or providers can expose services using standard Hessian while consumers call it using Dubbo’s Hessian protocol.

Constraints

  • Parameters and return values must implement the Serializable interface.
  • Parameters and return values cannot implement interfaces like List, Map, Number, Date, Calendar, etc., via custom implementations; only JDK’s built-in implementations can be used, as Hessian applies special processing that causes property values in custom classes to be lost.

Usage Scenarios

Hessian is a lightweight RPC service implemented based on Binary-RPC protocol, demonstrating serialization and deserialization instances.

Usage

Dependencies

As of Dubbo 3, the Hessian protocol is no longer embedded in Dubbo and needs to be separately introduced as an independent module.

  1. <dependency>
  2. <groupId>org.apache.dubbo.extensions</groupId>
  3. <artifactId>dubbo-rpc-hessian</artifactId>
  4. <version>3.3.0</version>
  5. </dependency>
  1. <dependency>
  2. <groupId>com.caucho</groupId>
  3. <artifactId>hessian</artifactId>
  4. <version>4.0.7</version>
  5. </dependency>

Define Hessian Protocol

  1. <dubbo:protocol name="hessian" port="8080" server="jetty" />

Set Default Protocol

  1. <dubbo:provider protocol="hessian" />

Set Service Protocol

  1. <dubbo:service protocol="hessian" />

Multiple Ports

  1. <dubbo:protocol id="hessian1" name="hessian" port="8080" />
  2. <dubbo:protocol id="hessian2" name="hessian" port="8081" />

Direct Connection

  1. <dubbo:reference id="helloService" interface="HelloWorld" url="hessian://10.20.153.10:8080/helloWorld" />

Feedback

Was this page helpful?

Yes No

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