Skip to content

Commit bc1204b

Browse files
Spike an exception based approach (#1698)
* Spike an exception based approach (misses removing the bool value return type) * Extend the use of `_confirmSemaphore` to the duration of when exceptions could be caught. * * Restore how @danielmarbach serialized the publish sequence number. * Fix test * * Fix bug in how headers are added to `BasicProperties` that don't already have them. * Use `ValueTask` as the `BasicPublishAsync` return value. --------- Co-authored-by: Daniel Marbach <[email protected]> Co-authored-by: Luke Bakken <[email protected]>
1 parent 04c2aaf commit bc1204b

18 files changed

+204
-255
lines changed

projects/RabbitMQ.Client/IChannel.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,12 @@ Task<string> BasicConsumeAsync(string queue, bool autoAck, string consumerTag, b
202202
/// <param name="basicProperties">The message properties.</param>
203203
/// <param name="body">The message body.</param>
204204
/// <param name="cancellationToken">CancellationToken for this operation.</param>
205-
/// <returns>Returns <c>true</c> if publisher confirmations enabled and the message was ack-ed</returns>
206205
/// <remarks>
207206
/// Routing key must be shorter than 255 bytes.
207+
/// TODO
208+
/// Throws <see cref="Exception"/> if a nack or basic.return is returned for the message.
208209
/// </remarks>
209-
ValueTask<bool> BasicPublishAsync<TProperties>(string exchange, string routingKey,
210+
ValueTask BasicPublishAsync<TProperties>(string exchange, string routingKey,
210211
bool mandatory, TProperties basicProperties, ReadOnlyMemory<byte> body,
211212
CancellationToken cancellationToken = default)
212213
where TProperties : IReadOnlyBasicProperties, IAmqpHeader;
@@ -220,11 +221,12 @@ ValueTask<bool> BasicPublishAsync<TProperties>(string exchange, string routingKe
220221
/// <param name="basicProperties">The message properties.</param>
221222
/// <param name="body">The message body.</param>
222223
/// <param name="cancellationToken">CancellationToken for this operation.</param>
223-
/// <returns>Returns <c>true</c> if publisher confirmations enabled and the message was ack-ed</returns>
224224
/// <remarks>
225225
/// Routing key must be shorter than 255 bytes.
226+
/// TODO
227+
/// Throws <see cref="Exception"/> if a nack or basic.return is returned for the message.
226228
/// </remarks>
227-
ValueTask<bool> BasicPublishAsync<TProperties>(CachedString exchange, CachedString routingKey,
229+
ValueTask BasicPublishAsync<TProperties>(CachedString exchange, CachedString routingKey,
228230
bool mandatory, TProperties basicProperties, ReadOnlyMemory<byte> body,
229231
CancellationToken cancellationToken = default)
230232
where TProperties : IReadOnlyBasicProperties, IAmqpHeader;

projects/RabbitMQ.Client/IChannelExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static Task<string> BasicConsumeAsync(this IChannel channel,
7878
/// <remarks>
7979
/// The publication occurs with mandatory=false.
8080
/// </remarks>
81-
public static ValueTask<bool> BasicPublishAsync<T>(this IChannel channel,
81+
public static ValueTask BasicPublishAsync<T>(this IChannel channel,
8282
PublicationAddress addr,
8383
T basicProperties,
8484
ReadOnlyMemory<byte> body,
@@ -94,7 +94,7 @@ public static ValueTask<bool> BasicPublishAsync<T>(this IChannel channel,
9494
/// <remarks>
9595
/// The publication occurs with mandatory=false and empty BasicProperties
9696
/// </remarks>
97-
public static ValueTask<bool> BasicPublishAsync(this IChannel channel,
97+
public static ValueTask BasicPublishAsync(this IChannel channel,
9898
string exchange,
9999
string routingKey,
100100
ReadOnlyMemory<byte> body,
@@ -109,7 +109,7 @@ public static ValueTask<bool> BasicPublishAsync(this IChannel channel,
109109
/// <remarks>
110110
/// The publication occurs with mandatory=false and empty BasicProperties
111111
/// </remarks>
112-
public static ValueTask<bool> BasicPublishAsync(this IChannel channel,
112+
public static ValueTask BasicPublishAsync(this IChannel channel,
113113
CachedString exchange,
114114
CachedString routingKey,
115115
ReadOnlyMemory<byte> body,
@@ -124,7 +124,7 @@ public static ValueTask<bool> BasicPublishAsync(this IChannel channel,
124124
/// <remarks>
125125
/// The publication occurs with empty BasicProperties
126126
/// </remarks>
127-
public static ValueTask<bool> BasicPublishAsync(this IChannel channel,
127+
public static ValueTask BasicPublishAsync(this IChannel channel,
128128
string exchange,
129129
string routingKey,
130130
bool mandatory,
@@ -140,7 +140,7 @@ public static ValueTask<bool> BasicPublishAsync(this IChannel channel,
140140
/// <remarks>
141141
/// The publication occurs with empty BasicProperties
142142
/// </remarks>
143-
public static ValueTask<bool> BasicPublishAsync(this IChannel channel,
143+
public static ValueTask BasicPublishAsync(this IChannel channel,
144144
CachedString exchange,
145145
CachedString routingKey,
146146
bool mandatory,

projects/RabbitMQ.Client/Impl/AutorecoveringChannel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,15 @@ await _connection.RecordConsumerAsync(rc, recordedEntitiesSemaphoreHeld: false)
311311
public Task<BasicGetResult?> BasicGetAsync(string queue, bool autoAck, CancellationToken cancellationToken)
312312
=> InnerChannel.BasicGetAsync(queue, autoAck, cancellationToken);
313313

314-
public ValueTask<bool> BasicPublishAsync<TProperties>(string exchange, string routingKey,
314+
public ValueTask BasicPublishAsync<TProperties>(string exchange, string routingKey,
315315
bool mandatory,
316316
TProperties basicProperties,
317317
ReadOnlyMemory<byte> body,
318318
CancellationToken cancellationToken = default)
319319
where TProperties : IReadOnlyBasicProperties, IAmqpHeader
320320
=> InnerChannel.BasicPublishAsync(exchange, routingKey, mandatory, basicProperties, body, cancellationToken);
321321

322-
public ValueTask<bool> BasicPublishAsync<TProperties>(CachedString exchange, CachedString routingKey,
322+
public ValueTask BasicPublishAsync<TProperties>(CachedString exchange, CachedString routingKey,
323323
bool mandatory,
324324
TProperties basicProperties,
325325
ReadOnlyMemory<byte> body,

0 commit comments

Comments
 (0)