KubeMQ
LearnEvents StoreHow-To Guides

Configure Retention

Set time-based, size-based, or count-based retention policies for stored events.

Events Store persists messages to disk. Without retention policies, storage grows indefinitely. KubeMQ provides three types of retention controls: time-based, size-based, and count-based. You can combine them — the most restrictive policy wins.

Retention Options

SettingConfig KeyDefaultDescription
Max retention timeStore.MaxRetention1440 (24 hours)Maximum age of messages in minutes. 0 = unlimited.
Max channel sizeStore.MaxQueueSize0 (unlimited)Maximum total bytes per channel. Oldest removed when exceeded.
Max message countStore.MaxMessages0 (unlimited)Maximum messages per channel. Oldest removed when exceeded.
Inactive channel purgeStore.MaxPurgeInactive1440 (24 hours)Minutes of inactivity before an empty channel is purged.

How Retention Works

As events accumulate, KubeMQ checks each retention threshold and purges the oldest events by time, size, or count — keeping everything that still fits within every limit.

Configure via Docker

Set retention options using environment variables:

docker run -d \  --name kubemq \  -p 50000:50000 \  -p 9090:9090 \  -p 8080:8080 \  -e KUBEMQ_TOKEN=YOUR_LICENSE_KEY \  -e STORE_MAX_RETENTION=4320 \  -e STORE_MAX_QUEUE_SIZE=1073741824 \  -e STORE_MAX_MESSAGES=1000000 \  -e STORE_MAX_PURGE_INACTIVE=10080 \  europe-docker.pkg.dev/kubemq/images/kubemq:next

This configures:

  • 3-day retention (4320 minutes)
  • 1 GB max per channel (1073741824 bytes)
  • 1 million messages max per channel
  • 7-day inactive channel purge (10080 minutes)

Configure via Helm

Set retention in your values.yaml:

values.yaml
store:
  maxRetention: 4320
  maxQueueSize: 1073741824
  maxMessages: 1000000
  maxPurgeInactive: 10080

Then install or upgrade:

helm upgrade kubemq kubemq/kubemq --values values.yaml

Configure via Kubernetes Operator

Set retention in the KubeMQ CRD:

kubemq-cluster.yaml
apiVersion: core.k8s.kubemq.io/v1beta1
kind: KubemqCluster
metadata:
  name: kubemq
spec:
  store:
    maxRetention: 4320
    maxQueueSize: 1073741824
    maxMessages: 1000000
    maxPurgeInactive: 10080

Common Retention Strategies

Development (Short Retention)

STORE_MAX_RETENTION=60          # 1 hour
STORE_MAX_MESSAGES=10000        # 10K messages
STORE_CLEAN_STORE=true          # Clean on restart

Production — Event Streaming

STORE_MAX_RETENTION=10080       # 7 days
STORE_MAX_QUEUE_SIZE=5368709120 # 5 GB per channel
STORE_MAX_MESSAGES=0            # Unlimited messages

Production — Event Sourcing

STORE_MAX_RETENTION=0           # Unlimited (no time expiry)
STORE_MAX_QUEUE_SIZE=0          # Unlimited size
STORE_MAX_MESSAGES=0            # Unlimited messages

Setting all retention values to 0 (unlimited) means events are stored indefinitely. Monitor disk usage with the storage utilization thresholds to prevent disk exhaustion.

Production — Compliance (Fixed Window)

STORE_MAX_RETENTION=525600      # 365 days (1 year)
STORE_MAX_QUEUE_SIZE=0          # Unlimited size
STORE_MAX_MESSAGES=0            # Unlimited messages
STORE_MAX_PURGE_INACTIVE=525600 # Purge inactive after 1 year

Persistence and Recovery

Clean Start

To clear all stored data on startup:

docker run -d \  --name kubemq \  -p 50000:50000 \  -p 9090:9090 \  -p 8080:8080 \  -e KUBEMQ_TOKEN=YOUR_LICENSE_KEY \  -e STORE_CLEAN_STORE=true \  europe-docker.pkg.dev/kubemq/images/kubemq:next

Volume Persistence

For data to survive container restarts, mount a volume to the store path:

docker run -d \  --name kubemq \  -p 50000:50000 \  -e KUBEMQ_TOKEN=YOUR_LICENSE_KEY \  --hostname kubemq \  -v kubemq-data:/kubemq/store \  europe-docker.pkg.dev/kubemq/images/kubemq:next

Recovery from Corruption

If the server detects recovery errors on startup, it automatically removes and recreates the store directory. The TruncateUnexpectedEOF option (enabled by default) truncates corrupted file tails rather than failing.

File store tuning (WriteBufferSize, ReadBufferSize, DiskSyncSeconds, etc.) is rarely needed. The defaults are suitable for most workloads. See the Events Store Reference for advanced settings.

Was this page helpful?

On this page