# org.apache.kafka.common.errors.UnsupportedCompressionTypeException：不支持的压缩类型。

- **ID:** `kafka/unsupported-compression-type`
- **领域:** kafka
- **类别:** protocol_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

代理或客户端收到带有压缩编解码器（例如 lz4、snappy、zstd）的消息，该编解码器在代理配置中未启用或不受支持。

## 解决方案

1. ```
   Enable the compression type in broker's server.properties: `compression.type=producer` (auto-detect) or explicitly set `zstd` if using zstd. Then restart the broker. Example: `echo 'compression.type=zstd' >> config/server.properties && kafka-server-stop.sh && kafka-server-start.sh config/server.properties`.
   ```

## 无效尝试

- **** — Upgrading the client library without changing broker config (e.g., enabling zstd on broker) still fails because the broker rejects unknown compression. (75% 失败率)
- **** — Disabling compression on the producer without fixing the broker may hide the symptom but loses efficiency; the root cause is the broker not supporting the codec. (60% 失败率)
