Compression DataConverter Sample
May 15, 2026 ยท View on GitHub
A custom Cadence DataConverter that JSON-encodes workflow data and then gzip-compresses the bytes. For repetitive JSON payloads this typically achieves 60-80% size reduction, lowering storage cost and bandwidth without changing any workflow or activity code. The decode path caps decompressed payloads (default 10 MB) so a malformed input cannot drive unbounded memory growth.
- Task list:
data-compression - Workflow type:
CompressedDataConverterWorkflow
Prerequisites
- Cadence server running (e.g. Docker Compose from the Cadence repo).
- From the repo root, build:
./gradlew build.
Register the domain (required once per cluster)
./gradlew -q execute -PmainClass=com.uber.cadence.samples.common.RegisterDomain
Or with the Cadence CLI:
cadence --domain samples-domain domain register
Run the worker (terminal 1)
The worker prints a compression statistics banner showing the before/after sizes of the sample payload, then begins polling the data-compression task list:
./gradlew -q execute -PmainClass=com.uber.cadence.samples.compression.CompressionWorker
Start a workflow (terminal 2)
./gradlew -q execute -PmainClass=com.uber.cadence.samples.compression.CompressionStarter
Or from the Cadence CLI:
cadence --domain samples-domain \
workflow start \
--workflow_type CompressedDataConverterWorkflow \
--tl data-compression \
--et 60
How it works
toData: JSON-encode the arguments with the standardJsonDataConverter, then write the bytes throughjava.util.zip.GZIPOutputStream.fromData/fromDataArray: decompress throughGZIPInputStreamwith a configurable max output cap, then delegate to the standardJsonDataConverter.
Source layout
| File | Purpose |
|---|---|
CompressedJsonDataConverter.java | The custom DataConverter |
CompressedDataConverterWorkflow.java | Workflow + activity + sample LargePayload POJOs and generator |
CompressionWorker.java | Worker main; wires the converter into WorkflowClientOptions and prints the stats banner |
CompressionStarter.java | Thin async starter |