| | | 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 CoreWCF.Queue.Common.Configuration; |
| | | 6 | | using CoreWCF.Runtime; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Channels |
| | | 9 | | { |
| | | 10 | | public abstract class MsmqBindingElementBase : QueueBaseTransportBindingElement |
| | | 11 | | { |
| | | 12 | | private DeadLetterQueue _deadLetterQueue; |
| | | 13 | | private int _maxRetryCycles; |
| | | 14 | | private int _receiveRetryCount; |
| | | 15 | | private TimeSpan _retryCycleDelay; |
| | | 16 | | private TimeSpan _timeToLive; |
| | | 17 | | |
| | | 18 | | //private ReceiveErrorHandling receiveErrorHandling; |
| | | 19 | | |
| | 0 | 20 | | public Uri CustomDeadLetterQueue { get; set; } |
| | | 21 | | |
| | | 22 | | public DeadLetterQueue DeadLetterQueue |
| | | 23 | | { |
| | 0 | 24 | | get { return _deadLetterQueue; } |
| | | 25 | | set |
| | | 26 | | { |
| | 0 | 27 | | if (!DeadLetterQueueHelper.IsDefined(value)) |
| | | 28 | | { |
| | 0 | 29 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val |
| | | 30 | | } |
| | | 31 | | |
| | 0 | 32 | | _deadLetterQueue = value; |
| | 0 | 33 | | } |
| | | 34 | | } |
| | | 35 | | |
| | 0 | 36 | | public bool ExactlyOnce { get; set; } |
| | | 37 | | |
| | | 38 | | // todo: need to be enabled when we add System.Transactions support |
| | | 39 | | //public int ReceiveRetryCount |
| | | 40 | | //{ |
| | | 41 | | // get { return _receiveRetryCount; } |
| | | 42 | | // set |
| | | 43 | | // { |
| | | 44 | | // if (value < 0) |
| | | 45 | | // { |
| | | 46 | | // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( |
| | | 47 | | // new ArgumentOutOfRangeException(nameof(value), value, "MsmqNonNegativeArgumentExpected")); |
| | | 48 | | // } |
| | | 49 | | |
| | | 50 | | // _receiveRetryCount = value; |
| | | 51 | | // } |
| | | 52 | | //} |
| | | 53 | | |
| | | 54 | | // todo: need to be enabled when we add System.Transactions support |
| | | 55 | | //public int MaxRetryCycles |
| | | 56 | | //{ |
| | | 57 | | // get { return _maxRetryCycles; } |
| | | 58 | | // set |
| | | 59 | | // { |
| | | 60 | | // if (value < 0) |
| | | 61 | | // { |
| | | 62 | | // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( |
| | | 63 | | // new ArgumentOutOfRangeException(nameof(value), value, "MsmqNonNegativeArgumentExpected")); |
| | | 64 | | // } |
| | | 65 | | |
| | | 66 | | // _maxRetryCycles = value; |
| | | 67 | | // } |
| | | 68 | | //} |
| | | 69 | | |
| | 0 | 70 | | public MsmqTransportSecurity MsmqTransportSecurity { get; internal set; } |
| | | 71 | | |
| | 0 | 72 | | public bool ReceiveContextEnabled { get; set; } |
| | | 73 | | |
| | | 74 | | ///// <summary>Gets or sets an enumeration value that specifies how poison and other messages that cannot be dis |
| | | 75 | | ///// <returns>A <see cref="T:System.ServiceModel.ReceiveErrorHandling" /> value that specifies how poison and o |
| | | 76 | | ///// <exception cref="T:System.ArgumentOutOfRangeException">The value is not within the range of values defined |
| | | 77 | | //public ReceiveErrorHandling ReceiveErrorHandling |
| | | 78 | | //{ |
| | | 79 | | // get |
| | | 80 | | // { |
| | | 81 | | // return receiveErrorHandling; |
| | | 82 | | // } |
| | | 83 | | // set |
| | | 84 | | // { |
| | | 85 | | // if (!ReceiveErrorHandlingHelper.IsDefined(value)) |
| | | 86 | | // { |
| | | 87 | | // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(v |
| | | 88 | | // } |
| | | 89 | | // receiveErrorHandling = value; |
| | | 90 | | // } |
| | | 91 | | //} |
| | | 92 | | |
| | | 93 | | |
| | | 94 | | public TimeSpan RetryCycleDelay |
| | | 95 | | { |
| | 0 | 96 | | get { return _retryCycleDelay; } |
| | | 97 | | set |
| | | 98 | | { |
| | 0 | 99 | | if (value < TimeSpan.Zero) |
| | | 100 | | { |
| | 0 | 101 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException()); |
| | | 102 | | } |
| | | 103 | | |
| | 0 | 104 | | if (TimeoutHelper.IsTooLarge(value)) |
| | | 105 | | { |
| | 0 | 106 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException()); |
| | | 107 | | } |
| | | 108 | | |
| | 0 | 109 | | _retryCycleDelay = value; |
| | 0 | 110 | | } |
| | | 111 | | } |
| | | 112 | | |
| | 0 | 113 | | public bool UseSourceJournal { get; set; } |
| | | 114 | | |
| | | 115 | | //internal virtual string WsdlTransportUri => null; |
| | | 116 | | |
| | 0 | 117 | | internal MsmqBindingElementBase() |
| | | 118 | | { |
| | 0 | 119 | | CustomDeadLetterQueue = null; |
| | 0 | 120 | | _deadLetterQueue = DeadLetterQueue.System; |
| | 0 | 121 | | ExactlyOnce = true; |
| | 0 | 122 | | _maxRetryCycles = 2; |
| | 0 | 123 | | ReceiveContextEnabled = true; |
| | | 124 | | //receiveErrorHandling = ReceiveErrorHandling.Fault; |
| | 0 | 125 | | _receiveRetryCount = 5; |
| | 0 | 126 | | _retryCycleDelay = MsmqDefaults.RetryCycleDelay; |
| | 0 | 127 | | _timeToLive = MsmqDefaults.TimeToLive; |
| | 0 | 128 | | MsmqTransportSecurity = new MsmqTransportSecurity(); |
| | 0 | 129 | | UseSourceJournal = false; |
| | | 130 | | //ReceiveContextSettings = new MsmqReceiveContextSettings(); |
| | 0 | 131 | | } |
| | | 132 | | |
| | | 133 | | internal MsmqBindingElementBase(MsmqBindingElementBase elementToBeCloned) |
| | 0 | 134 | | : base(elementToBeCloned) |
| | | 135 | | { |
| | 0 | 136 | | CustomDeadLetterQueue = elementToBeCloned.CustomDeadLetterQueue; |
| | 0 | 137 | | _deadLetterQueue = elementToBeCloned._deadLetterQueue; |
| | 0 | 138 | | ExactlyOnce = elementToBeCloned.ExactlyOnce; |
| | 0 | 139 | | _maxRetryCycles = elementToBeCloned._maxRetryCycles; |
| | | 140 | | //msmqTransportSecurity = new MsmqTransportSecurity(elementToBeCloned.MsmqTransportSecurity); |
| | 0 | 141 | | ReceiveContextEnabled = elementToBeCloned.ReceiveContextEnabled; |
| | | 142 | | //receiveErrorHandling = elementToBeCloned.receiveErrorHandling; |
| | 0 | 143 | | _receiveRetryCount = elementToBeCloned._receiveRetryCount; |
| | 0 | 144 | | _retryCycleDelay = elementToBeCloned._retryCycleDelay; |
| | 0 | 145 | | _timeToLive = elementToBeCloned._timeToLive; |
| | 0 | 146 | | UseSourceJournal = elementToBeCloned.UseSourceJournal; |
| | | 147 | | //ReceiveContextSettings = elementToBeCloned.ReceiveContextSettings; |
| | 0 | 148 | | } |
| | | 149 | | |
| | | 150 | | public override T GetProperty<T>(BindingContext context) |
| | | 151 | | { |
| | 0 | 152 | | if (context == null) |
| | | 153 | | { |
| | 0 | 154 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context)); |
| | | 155 | | } |
| | | 156 | | |
| | 0 | 157 | | if (typeof(T) == typeof(ISecurityCapabilities)) |
| | | 158 | | { |
| | 0 | 159 | | return null; |
| | | 160 | | } |
| | | 161 | | |
| | 0 | 162 | | return base.GetProperty<T>(context); |
| | | 163 | | } |
| | | 164 | | } |
| | | 165 | | } |