| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.Channels.Configuration |
| | | 8 | | { |
| | | 9 | | public static class RabbitMqQuorumQueueXArgument |
| | | 10 | | { |
| | | 11 | | public static readonly string DeliveryLimit = "x-delivery-limit"; |
| | | 12 | | } |
| | | 13 | | |
| | | 14 | | public class QuorumQueueConfiguration : QueueDeclareConfiguration |
| | | 15 | | { |
| | 8 | 16 | | private int _deliveryLimit = 3; |
| | | 17 | | |
| | 4 | 18 | | public override string QueueType => RabbitMqQueueType.Quorum; |
| | | 19 | | |
| | | 20 | | public override bool Durable |
| | | 21 | | { |
| | | 22 | | get |
| | | 23 | | { |
| | 3 | 24 | | return true; |
| | | 25 | | } |
| | | 26 | | set |
| | | 27 | | { |
| | 1 | 28 | | if (!value) |
| | | 29 | | { |
| | 1 | 30 | | throw new ArgumentException(SR.Format(SR.UnsupportedQuorumQueuePropertyValue, nameof(Durable), false |
| | | 31 | | } |
| | 0 | 32 | | } |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | public override bool Exclusive |
| | | 36 | | { |
| | | 37 | | get |
| | | 38 | | { |
| | 3 | 39 | | return false; |
| | | 40 | | } |
| | | 41 | | set |
| | | 42 | | { |
| | 1 | 43 | | if (value) |
| | | 44 | | { |
| | 1 | 45 | | throw new ArgumentException(SR.Format(SR.UnsupportedQuorumQueuePropertyValue, nameof(Exclusive), tru |
| | | 46 | | } |
| | 0 | 47 | | } |
| | | 48 | | } |
| | | 49 | | |
| | | 50 | | public override bool GlobalQosPrefetch |
| | | 51 | | { |
| | | 52 | | get |
| | | 53 | | { |
| | 3 | 54 | | return false; |
| | | 55 | | } |
| | | 56 | | set |
| | | 57 | | { |
| | 1 | 58 | | if (value) |
| | | 59 | | { |
| | 1 | 60 | | throw new ArgumentException(SR.Format(SR.UnsupportedQuorumQueuePropertyValue, nameof(GlobalQosPrefet |
| | | 61 | | } |
| | 0 | 62 | | } |
| | | 63 | | } |
| | | 64 | | |
| | | 65 | | public int DeliveryLimit |
| | | 66 | | { |
| | | 67 | | get |
| | | 68 | | { |
| | 3 | 69 | | return _deliveryLimit; |
| | | 70 | | } |
| | | 71 | | set |
| | | 72 | | { |
| | 0 | 73 | | if (value < 1) |
| | | 74 | | { |
| | 0 | 75 | | throw new ArgumentException(SR.Format(SR.UnsupportedQuorumQueuePropertyValue, nameof(DeliveryLimit), |
| | | 76 | | } |
| | | 77 | | |
| | 0 | 78 | | _deliveryLimit = value; |
| | 0 | 79 | | } |
| | | 80 | | } |
| | | 81 | | |
| | | 82 | | internal override Dictionary<string, object> ToDictionary() |
| | | 83 | | { |
| | 3 | 84 | | var queueXArgs = base.ToDictionary(); |
| | 3 | 85 | | queueXArgs[RabbitMqQuorumQueueXArgument.DeliveryLimit] = DeliveryLimit; |
| | | 86 | | |
| | 3 | 87 | | return queueXArgs; |
| | | 88 | | } |
| | | 89 | | } |
| | | 90 | | } |