blob: 8e465d71fd870e51728ad9e48ade29dd608bb1fe [file] [log] [blame]
[[zipdeflater-dataformat]]
= Zip Deflate Compression DataFormat
:page-source: components/camel-zip-deflater/src/main/docs/zipdeflater-dataformat.adoc
*Available as of Camel version 2.12*
The Zip Deflater Data Format is a message compression and
de-compression format. Messages marshalled using Zip compression can be
unmarshalled using Zip 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. It facilitates more optimal use of
network bandwidth while incurring a small cost in order to compress and
decompress payloads at the endpoint.
NOTE: This dataformat is not for working with zip files such as uncompressing and building zip files.
Instead use the zipfile dataformat.
== Options
// dataformat options: START
The Zip Deflate Compression dataformat supports 2 options, which are listed below.
[width="100%",cols="2s,1m,1m,6",options="header"]
|===
| Name | Default | Java Type | Description
| compressionLevel | -1 | Integer | To specify a specific compression between 0-9. -1 is default compression, 0 is no compression, and 9 is best compression.
| contentTypeHeader | false | Boolean | 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.
|===
// dataformat options: END
== Marshal
In this example we marshal a regular text/XML payload to a compressed
payload employing zip compression `Deflater.BEST_COMPRESSION` and send
it an ActiveMQ queue called MY_QUEUE.
[source,java]
----
from("direct:start").marshal().zipDeflater(Deflater.BEST_COMPRESSION).to("activemq:queue:MY_QUEUE");
----
Alternatively if you would like to use the default setting you could
send it as
[source,java]
----
from("direct:start").marshal().zipDeflater().to("activemq:queue:MY_QUEUE");
----
== Unmarshal
In this example we unmarshal a zipped payload from an ActiveMQ queue
called MY_QUEUE to its original format, and forward it for processing to
the UnZippedMessageProcessor. Note that the compression Level employed
during the marshalling should be identical to the one employed during
unmarshalling to avoid errors.
[source,java]
----
from("activemq:queue:MY_QUEUE").unmarshal().zipDeflater().process(new UnZippedMessageProcessor());
----