GZip Deflater
Since Camel 2.0
The GZip Deflater Data Format is a message compression and
de-compression format. It uses the same deflate algorithm that is used
in the Zip data format, although some additional
headers are provided. This format is produced by popular gzip
/gunzip
tool. Messages marshalled using GZip compression can be unmarshalled
using GZip decompression just prior to being consumed at the endpoint.
The compression capability is quite useful when you deal with large XML
and Text based payloads or when you read messages previously comressed
using gzip
tool.
This dataformat is not for working with gzip files such as uncompressing and building gzip files. Instead use the zipfile dataformat. |
Options
The GZip Deflater dataformat supports 1 options, which are listed below.
Name | Default | Java Type | Description |
---|---|---|---|
contentTypeHeader |
|
|
Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSon etc. |
Marshal
In this example we marshal a regular text/XML payload to a compressed payload employing gzip compression format and send it an ActiveMQ queue called MY_QUEUE.
from("direct:start").marshal().gzipDeflater().to("activemq:queue:MY_QUEUE");
Unmarshal
In this example we unmarshal a gzipped payload from an ActiveMQ queue
called MY_QUEUE to its original format, and forward it for processing to
the UnGZippedMessageProcessor
.
from("activemq:queue:MY_QUEUE").unmarshal().gzipDeflater().process(new UnGZippedMessageProcessor());
Spring Boot Auto-Configuration
When using zip-deflater with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-zip-deflater-starter</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
The component supports 5 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
camel.dataformat.gzipdeflater.content-type-header |
Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc. |
false |
Boolean |
camel.dataformat.gzipdeflater.enabled |
Whether to enable auto configuration of the gzipdeflater data format. This is enabled by default. |
Boolean |
|
camel.dataformat.zipdeflater.compression-level |
To specify a specific compression between 0-9. -1 is default compression, 0 is no compression, and 9 is best compression. |
-1 |
Integer |
camel.dataformat.zipdeflater.content-type-header |
Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSON etc. |
false |
Boolean |
camel.dataformat.zipdeflater.enabled |
Whether to enable auto configuration of the zipdeflater data format. This is enabled by default. |
Boolean |