Commit 6a31a46
committed
Add automatic publisher confirmation tracking with async API
Traditional publisher confirms in the Java client require manual tracking
of sequence numbers and correlation of Basic.Return messages. This makes
per-message error handling complex and provides no built-in async pattern.
This change introduces automatic publisher confirmation tracking with a
`CompletableFuture`-based API, following the design of the .NET client's
publisher confirmation implementation. When enabled via `ChannelOptions`,
the library automatically tracks each message's confirmation status and
completes futures when the broker sends Basic.Ack, Basic.Nack, or
Basic.Return.
New API methods:
- `Channel.basicPublishAsync()` - Returns `CompletableFuture<Void>` that
completes when broker confirms the message
- `Connection.createChannel(ChannelOptions)` - Creates channel with
publisher confirmation tracking enabled
New classes:
- `ChannelOptions` - Configuration for channel creation with tracking
settings and optional limit on outstanding confirmations
- `PublishException` - Exception thrown when message is nack'd or returned,
with full details including sequence number and routing information
- `InternalException` - Exception for internal library bugs with GitHub
issue reporting instructions
The implementation adds a sequence number header (`x-java-pub-seq-no`) to
each tracked message, allowing correlation of Basic.Return responses with
specific messages. When `maxOutstandingConfirms` is set, `basicPublishAsync()`
blocks if the limit is reached, providing backpressure to prevent unbounded
memory growth.
The feature is opt-in and maintains full backward compatibility. Existing
`basicPublish()` and `waitForConfirms()` methods remain unchanged.1 parent 3ba79f4 commit 6a31a46
File tree
15 files changed
+1546
-14
lines changed- doc
- src
- main/java/com/rabbitmq/client
- impl
- recovery
- test/java/com/rabbitmq/client/test/functional
15 files changed
+1546
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
91 | 103 | | |
92 | 104 | | |
93 | 105 | | |
94 | 106 | | |
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
98 | | - | |
| 110 | + | |
99 | 111 | | |
100 | 112 | | |
101 | 113 | | |
| |||
0 commit comments