feat: batch enqueue, delivery batching, and smart batching modes
Merged
VI
8mo ago+1023+1023+0123456789012345678901234567890123456789-21-21-01234567890123456789
Summary
- Add
batchEnqueue(List<EnqueueMessage>)method for explicit batch enqueue viaBatchEnqueueRPC - Add transparent delivery batching in consume stream -- unpacks
ConsumeResponse.messages(repeated field) with singularmessagefallback for backward compatibility - Add
BatchModewith three modes:AUTO(opportunistic, default),LINGER(timer-based),DISABLED enqueue()now routes through background batcher by default (zero config, zero latency penalty at low load)- Single-item optimization: 1 message uses regular
EnqueueRPC (preserves exact error types likeQueueNotFoundException), 2+ messages useBatchEnqueue close()drains pending batched messages before disconnecting- Update proto to include
BatchEnqueueRPC andConsumeResponse.messagesrepeated field
Test plan
-
BatchModeTest-- 7 unit tests for mode configuration and validation -
BatchEnqueueResultTest-- 4 unit tests for success/error result types -
BuilderTest-- 4 new tests for batch mode builder options (11 total) -
BatchClientTest-- 8 integration tests: explicit batch, mixed queue results, auto batching, linger batching, disabled batching, multi-message consume, error propagation through batcher, default mode verification - All 34 tests pass (TlsAuthClientTest failure is pre-existing)
Generated with Claude Code
Summary by cubic
Adds explicit batch enqueue, client-side smart batching for enqueue(), and delivery batching for consume(). Default mode is AUTO, which coalesces messages under load without adding latency at low load.
-
New Features
- Added
batchEnqueue(List<EnqueueMessage>)with per-messageBatchEnqueueResult. - Added delivery batching:
consume()now unpacksConsumeResponse.messageswith singular fallback. - Introduced
BatchMode:AUTO(default),LINGER,DISABLED. enqueue()routes through a background batcher by default; 1 message usesEnqueue, 2+ useBatchEnqueue.close()now drains pending batched messages.- Updated proto with
BatchEnqueueRPC and batchedConsumeResponse.messages.
- Added
-
Migration
- Requires a server that implements
BatchEnqueueto benefit from batching; usewithBatchMode(BatchMode.disabled())to stay compatible with older servers. - No changes needed for consumers; the client transparently handles batched and single-message responses.
- Requires a server that implements