Enforce producer and consumer settingsv1.3+
This Request Rule Validator policy enforces client settings on Produce and Fetch requests.
In this example, for produce requests:
- Producers must set
ackstoall(-1), so that every in-sync replica stores a record before the broker acknowledges it. - If a producer uses transactions, its transactional ID must start with
team-a..
For fetch requests:
- Consumers must use the
read_committedisolation level, so that they don’t read records from aborted transactions. - Consumers must set
fetch.max.wait.msto at least 100 ms, so that the broker can hold a fetch until data is available instead of returning empty responses in a tight loop. - A fetch response can be at most 50 MiB (
fetch.max.bytes).
The default fetch settings of most Kafka clients match these limits: consumers set fetch.max.wait.ms to 500 ms and fetch at most 50 MiB.
Most clients use read_uncommitted by default, so consumers must set isolation.level=read_committed explicitly.
A consumer that breaks a fetch rule doesn’t receive any records. For example, the Java consumer stops with IllegalStateException: Unexpected error code 44.
When a request doesn’t match a rule, Event Gateway rejects the entire request with the Kafka POLICY_VIOLATION error code.
The Produce and Fetch responses don’t carry an error message, so clients only receive the error code, not the rule description.
A producer with
acks=0doesn’t wait for a response. If Event Gateway rejects its records, the producer doesn’t receive an error, and the records are lost.