The serialization process is to convert a Java object into a byte array to be transmitted over a network. Deserialization converts a byte array into a Java object.

Consider compatibility, performance, and other factors when selecting a serialization method. High-Speed Service Framework (HSF) supports serialization based on Java and hessian2, and hessian2 is used by default. The following table lists the differences and settings of the two serialization methods (configure only HSFApiProviderBean for the provider).

Serialization method Maven dependency Configuration Compatibility Performance
hessian2 <artifactId>hsf-io-serialize-hessian2</artifactId> setPreferSerializeType("hessian2") High High
Java <artifactId>hsf-io-serialize-java</artifactId> setPreferSerializeType("java") Highest Medium

Configure the serialization method for HSF services through API programming

HSFApiProviderBean hsfApiProviderBean = new HSFApiProviderBean();

Configure the serialization method for HSF services through Spring configuration

Spring is a framework widely used by applications. You can configure HSF services through Spring XML. The following XML configuration has the same effect as the preceding API programming:

<bean class="" init-method="init">
    <! --Set the interface for service publishing. -->
    <property name="serviceInterface" value=""/>
    <! -- Set "target" to [ref], which indicates the Spring bean ID of the HSF service to be published.-->
    <property name="target" ref="Referenced bean ID"/>
    <! --Set the version of the service. -->
    <property name="serviceVersion" value="1.0.0"/>
    <! --Set the group to which the service belongs. -->
    <property name="serviceGroup" value="HSF"/>
    <! --Set the service response time. -->
    <property name="clientTimeout" value="3000"/>
    <! --Sets the serialization type for transmitting the object in service implementation. -->
    <property name="preferSerializeType" value="hessian2"/>