MessagePack

本文介绍 MessagePack 序列化

1 介绍

MessagePack是一种计算机数据交换格式。它是一种二进制形式,用于表示简单的数据结构,如数组和关联数组。MessagePack 旨在尽可能紧凑和简单。

2 使用方式

2.1 添加依赖

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.apache.dubbo.extensions</groupId>
  4. <artifactId>dubbo-serialization-msgpack</artifactId>
  5. <version>3.3.0</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>org.msgpack</groupId>
  9. <artifactId>msgpack-core</artifactId>
  10. <version>0.9.3</version>
  11. </dependency>
  12. <dependency>
  13. <groupId>org.msgpack</groupId>
  14. <artifactId>jackson-dataformat-msgpack</artifactId>
  15. <version>0.9.3</version>
  16. </dependency>
  17. </dependencies>

2.2 配置启用

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

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

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

最后修改 September 13, 2024: Refactor website structure (#2860) (1a4b998f54b)