Cameleer

Zip Deflater data format

The zipDeflater data format compresses the message body with zlib/DEFLATE (marshal) and decompresses it (unmarshal), like Java's java.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.decompress in Python, Inflater in Java).
  • Cut bandwidth on edge links when both ends are under your control.

Marshal and unmarshal

directionbody inbody out
marshalany body (text is taken as UTF-8 bytes)zlib bytes (RFC 1950: 2-byte header, DEFLATE data, Adler-32 checksum)
unmarshalzlib bytesthe 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:

yaml example: zip-deflater-compress
- route:
    id: zlib-compress
    from:
      uri: direct:zlib-compress
      steps:
        - marshal:
            zipDeflater: {}
        - marshal:
            base64: {}
text
hello hello hello hello
text
eJzLSM3JyVfAIAFoAwix

And decompress it again:

yaml example: zip-deflater-decompress
- route:
    id: zlib-decompress
    from:
      uri: direct:zlib-decompress
      steps:
        - unmarshal:
            base64: {}
        - unmarshal:
            zipDeflater: {}
        - convertBodyTo:
            type: String
text
eJzLSM3JyVfAIAFoAwix
text
hello hello hello hello

Rust DSL

rust
b.from("direct:zlib-rust")
    .marshal(DataFormatDefinition::zip_deflater())
    .unmarshal(DataFormatDefinition::zip_deflater());

Options

optiondefaultdescription
compressionLevel (level)60 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.

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.

Edit this page on GitHub