In version 3.1.0, the serialization protocol supported by Dubbo by default adds support for Fastjson2. Some users may consider upgrading the serialization protocol in the existing system, but the difference between the server and client versions may cause the client to not support the serialization protocol of the server. In version 3.2.0, Dubbo’s server introduces a new configuration prefer-serialization
, which can perfectly solve the possible risks in the server-side serialization upgrade process.
Serialization protocol upgrade needs to be done in two steps:
prefer-serialization
configuration needs to be added to the exposed configuration of the server. For example: the serialization protocol before the upgrade is hessian2, and the serialization protocol after the upgrade is Fastjson2, then the configuration shown below should be added to the exposed configuration of the server **dubbo.provider.prefer-serialization=fastjson2,hessian2
dubbo.provider.serialization=hessian2
The dubbo client serialization protocol is selected according to the registration configuration of the server (that is, the serialization
configuration of the server). In the request phase, dubbo will assemble the serialization protocol of the client into the request header, and the server will determine the deserialization protocol according to the request header when performing deserialization.
prefer-serialization
first when serializing the client. If the protocol related to prefer-serialization
is not supported, the protocol configured by serialization
will be used . (You can think of serialization
as a bottom-up configuration)