Zip Deflater data format
The
zipDeflaterdata format compresses the message body with zlib/DEFLATE (marshal) and decompresses it (unmarshal), like Java'sjava.util.zip.Deflater.
Name: zipDeflater · Also: zip, deflate, zlib, zipdeflater · Crate: cameleer-core · Cargo feature: none, always included (build features) ·
Apache Camel: Zip Deflater
When to use it
- Exchange compressed messages with Java Camel routes that use
zipDeflater. - Compress payloads stored in a database column, a cache or a queue where the zlib format is
expected (
zlib.decompressin Python,Inflaterin Java). - Cut bandwidth on edge links when both ends are under your control.
Marshal and unmarshal
| direction | body in | body out |
|---|---|---|
marshal | any body (text is taken as UTF-8 bytes) | zlib bytes (RFC 1950: 2-byte header, DEFLATE data, Adler-32 checksum) |
unmarshal | zlib bytes | the decompressed bytes |
This is not a .zip archive: for archives with file entries use zipFile.
Example
Compress a body and show it as Base64, so it fits in a JSON field:
- route:
id: zlib-compress
from:
uri: direct:zlib-compress
steps:
- marshal:
zipDeflater: {}
- marshal:
base64: {}hello hello hello helloeJzLSM3JyVfAIAFoAwixAnd decompress it again:
- route:
id: zlib-decompress
from:
uri: direct:zlib-decompress
steps:
- unmarshal:
base64: {}
- unmarshal:
zipDeflater: {}
- convertBodyTo:
type: StringeJzLSM3JyVfAIAFoAwixhello hello hello helloRust DSL
b.from("direct:zlib-rust")
.marshal(DataFormatDefinition::zip_deflater())
.unmarshal(DataFormatDefinition::zip_deflater());Options
| option | default | description |
|---|---|---|
compressionLevel (level) | 6 | 0 stores the data uncompressed; 1-9 compress. |
Common questions
Is the output compatible with Python's zlib module?
Yes. zlib.decompress(data) reads it, and zlib.compress(...) output unmarshals here.
Why is the name zip if it does not make a .zip file?
Apache Camel named it after java.util.zip.Deflater. Use zipFile for archives.
Related
Found a problem?
If something on this page doesn't match what Cameleer does, or you hit a bug while building
with it, please help fix it, whether you are a person or a coding agent:
open an issue that describes what you saw,
then fork the repository, fix it, add or update a test, run cargo test --workspace, and open
a pull request. CONTRIBUTING.md
explains the ground rules.