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
- Cadence server running (e.g. Docker Compose from the Cadence repo).
- From the repo root, build:
./gradlew build.
./gradlew -q execute -PmainClass=com.uber.cadence.samples.common.RegisterDomainOr with the Cadence CLI:
cadence --domain samples-domain domain registerThe 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./gradlew -q execute -PmainClass=com.uber.cadence.samples.compression.CompressionStarterOr from the Cadence CLI:
cadence --domain samples-domain \
workflow start \
--workflow_type CompressedDataConverterWorkflow \
--tl data-compression \
--et 60toData: 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.
| 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 |