diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..b76f328b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Pär Dahlman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/RawRabbit/Operations/Requester.cs b/src/RawRabbit/Operations/Requester.cs index 40abd86e..7a53bdb1 100644 --- a/src/RawRabbit/Operations/Requester.cs +++ b/src/RawRabbit/Operations/Requester.cs @@ -75,7 +75,7 @@ public Task RequestAsync(TRequest message, Guid _logger.LogWarning($"Unable to find request timer for {props.CorrelationId}."); } timer?.Dispose(); - responseTcs.TrySetException(new TimeoutException($"The request timed out after {_requestTimeout.ToString("g")}.")); + responseTcs.TrySetException(new TimeoutException($"The request '{props.CorrelationId}' timed out after {_requestTimeout.ToString("g")}.")); }, null, _requestTimeout, new TimeSpan(-1))); consumer.Model.BasicPublish( @@ -143,7 +143,16 @@ private IRawConsumer GetOrCreateConsumerForType(IConsumerConfiguratio { var tcs = tcsAsObj as TaskCompletionSource; _logger.LogDebug($"Recived response with correlationId {args.BasicProperties.CorrelationId}."); - _requestTimerDictionary[args.BasicProperties.CorrelationId]?.Dispose(); + + Timer timer; + if (_requestTimerDictionary.TryRemove(args.BasicProperties.CorrelationId, out timer)) + { + timer?.Dispose(); + } + else + { + _logger.LogInformation($"Unable to find request timer for message {args.BasicProperties.CorrelationId}."); + } _errorStrategy.OnResponseRecievedAsync(args, tcs); if (tcs?.Task?.IsFaulted ?? true) {