Skip to content

Commit af6ab1d

Browse files
authored
Remove default value (#145)
This PR aims to stop implicitly defaulting queue type to classic when creating/declaring a queue, allowing the broker to apply the vhost’s default queue type when the client does not explicitly set one. Changes: Removed QueueType getter from IQueueSpecification and AmqpQueueSpecification (and corresponding API tracking entries). Updated DeclareAsync() logic intended to apply mandatory settings for quorum/stream queues. Fixes: #146 --------- Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
1 parent 8472491 commit af6ab1d

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

RabbitMQ.AMQP.Client/IEntities.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public interface IQueueSpecification : IEntityInfoSpecification<IQueueInfo>
6161
public Dictionary<object, object> QueueArguments { get; }
6262
IQueueSpecification Arguments(Dictionary<object, object> queueArguments);
6363

64-
public QueueType QueueType { get; }
6564
IQueueSpecification Type(QueueType queueType);
6665

6766
IQueueSpecification DeadLetterExchange(string dlx);

RabbitMQ.AMQP.Client/Impl/AmqpQueueSpecification.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,26 +180,17 @@ public IQueueSpecification Arguments(Dictionary<object, object> queueArguments)
180180

181181
public Dictionary<object, object> QueueArguments => _queueArguments;
182182

183+
/// <summary>
184+
/// <param name="queueType">The type of the queue</param>
185+
/// If not set, the default is empty, which means the declaration will create a classic queue.
186+
/// <returns>The current <see cref="IQueueSpecification"/></returns>
187+
/// </summary>
183188
public IQueueSpecification Type(QueueType queueType)
184189
{
185190
_queueArguments["x-queue-type"] = queueType.ToString().ToLower();
186191
return this;
187192
}
188193

189-
public QueueType QueueType
190-
{
191-
get
192-
{
193-
if (!_queueArguments.ContainsKey("x-queue-type"))
194-
{
195-
return QueueType.CLASSIC;
196-
}
197-
198-
string type = (string)_queueArguments["x-queue-type"];
199-
return (QueueType)Enum.Parse(typeof(QueueType), type.ToUpperInvariant());
200-
}
201-
}
202-
203194
public IQueueSpecification DeadLetterExchange(string dlx)
204195
{
205196
_queueArguments["x-dead-letter-exchange"] = dlx;
@@ -307,7 +298,7 @@ public IQueueSpecification MessageTtl(TimeSpan ttl)
307298

308299
public async Task<IQueueInfo> DeclareAsync()
309300
{
310-
if (QueueType is QueueType.QUORUM or QueueType.STREAM)
301+
if (_queueArguments["x-queue-type"] is QueueType.QUORUM or QueueType.STREAM)
311302
{
312303
// mandatory arguments for quorum queues and streams
313304
Exclusive(false).AutoDelete(false);

RabbitMQ.AMQP.Client/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,6 @@ RabbitMQ.AMQP.Client.Impl.AmqpQueueSpecification.OverflowStrategy(RabbitMQ.AMQP.
488488
RabbitMQ.AMQP.Client.Impl.AmqpQueueSpecification.PurgeAsync() -> System.Threading.Tasks.Task<ulong>!
489489
RabbitMQ.AMQP.Client.Impl.AmqpQueueSpecification.QueueArguments.get -> System.Collections.Generic.Dictionary<object!, object!>!
490490
RabbitMQ.AMQP.Client.Impl.AmqpQueueSpecification.QueueName.get -> string!
491-
RabbitMQ.AMQP.Client.Impl.AmqpQueueSpecification.QueueType.get -> RabbitMQ.AMQP.Client.QueueType
492491
RabbitMQ.AMQP.Client.Impl.AmqpQueueSpecification.Quorum() -> RabbitMQ.AMQP.Client.IQuorumQueueSpecification!
493492
RabbitMQ.AMQP.Client.Impl.AmqpQueueSpecification.SingleActiveConsumer(bool singleActiveConsumer) -> RabbitMQ.AMQP.Client.IQueueSpecification!
494493
RabbitMQ.AMQP.Client.Impl.AmqpQueueSpecification.Stream() -> RabbitMQ.AMQP.Client.IStreamSpecification!
@@ -688,7 +687,6 @@ RabbitMQ.AMQP.Client.IQueueSpecification.OverflowStrategy(RabbitMQ.AMQP.Client.O
688687
RabbitMQ.AMQP.Client.IQueueSpecification.PurgeAsync() -> System.Threading.Tasks.Task<ulong>!
689688
RabbitMQ.AMQP.Client.IQueueSpecification.QueueArguments.get -> System.Collections.Generic.Dictionary<object!, object!>!
690689
RabbitMQ.AMQP.Client.IQueueSpecification.QueueName.get -> string!
691-
RabbitMQ.AMQP.Client.IQueueSpecification.QueueType.get -> RabbitMQ.AMQP.Client.QueueType
692690
RabbitMQ.AMQP.Client.IQueueSpecification.Quorum() -> RabbitMQ.AMQP.Client.IQuorumQueueSpecification!
693691
RabbitMQ.AMQP.Client.IQueueSpecification.SingleActiveConsumer(bool singleActiveConsumer) -> RabbitMQ.AMQP.Client.IQueueSpecification!
694692
RabbitMQ.AMQP.Client.IQueueSpecification.Stream() -> RabbitMQ.AMQP.Client.IStreamSpecification!

0 commit comments

Comments
 (0)