From 37f9e95c71db7093e875f079800e8ac709286efa Mon Sep 17 00:00:00 2001 From: sanych-sun Date: Tue, 3 Sep 2024 21:42:16 -0700 Subject: [PATCH] Set target framework --- Directory.Build.props | 2 ++ ...Q.Next.Examples.DemoSaslAuthMechanism.csproj | 1 - ...bitMQ.Next.Examples.DynamicSerializer.csproj | 1 - ...RabbitMQ.Next.Examples.SimpleConsumer.csproj | 1 - ...abbitMQ.Next.Examples.SimplePublisher.csproj | 1 - ...abbitMQ.Next.Examples.TopologyBuilder.csproj | 1 - .../RabbitMQ.Next.Abstractions.csproj | 1 - .../RabbitMQ.Next.Consumer.Abstractions.csproj | 1 - .../RabbitMQ.Next.Consumer.csproj | 1 - .../RabbitMQ.Next.Publisher.Abstractions.csproj | 1 - .../RabbitMQ.Next.Publisher.Attributes.csproj | 1 - .../RabbitMQ.Next.Publisher.csproj | 1 - .../RabbitMQ.Next.Serialization.Dynamic.csproj | 1 - ...bbitMQ.Next.Serialization.MessagePack.csproj | 1 - ...tMQ.Next.Serialization.NewtonsoftJson.csproj | 1 - ...RabbitMQ.Next.Serialization.PlainText.csproj | 1 - ...abbitMQ.Next.Serialization.SystemJson.csproj | 1 - ...tMQ.Next.TopologyBuilder.Abstractions.csproj | 1 - .../RabbitMQ.Next.TopologyBuilder.csproj | 1 - src/RabbitMQ.Next/Connection.cs | 17 +++++++++-------- src/RabbitMQ.Next/RabbitMQ.Next.csproj | 7 +------ src/RabbitMQ.Next/Tasks/TaskExtensions.cs | 11 +++++++---- .../RabbitMQ.Next.Tests.csproj | 1 - 23 files changed, 19 insertions(+), 37 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index da5f8cc8..fe7cd8ca 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,12 +1,14 @@ 0.4.0 + net6.0 latest Oleksandr Poliakov RabbitMQ;Messaging MIT git true + true An experimental low-level RabbitMQ client for .Net with number of high-level APIs diff --git a/docs/examples/RabbitMQ.Next.Examples.DemoSaslAuthMechanism/RabbitMQ.Next.Examples.DemoSaslAuthMechanism.csproj b/docs/examples/RabbitMQ.Next.Examples.DemoSaslAuthMechanism/RabbitMQ.Next.Examples.DemoSaslAuthMechanism.csproj index 125bf9de..fbbb2ec6 100644 --- a/docs/examples/RabbitMQ.Next.Examples.DemoSaslAuthMechanism/RabbitMQ.Next.Examples.DemoSaslAuthMechanism.csproj +++ b/docs/examples/RabbitMQ.Next.Examples.DemoSaslAuthMechanism/RabbitMQ.Next.Examples.DemoSaslAuthMechanism.csproj @@ -2,7 +2,6 @@ Exe - net6.0 false diff --git a/docs/examples/RabbitMQ.Next.Examples.DynamicSerializer/RabbitMQ.Next.Examples.DynamicSerializer.csproj b/docs/examples/RabbitMQ.Next.Examples.DynamicSerializer/RabbitMQ.Next.Examples.DynamicSerializer.csproj index 073d76ea..69be4c17 100644 --- a/docs/examples/RabbitMQ.Next.Examples.DynamicSerializer/RabbitMQ.Next.Examples.DynamicSerializer.csproj +++ b/docs/examples/RabbitMQ.Next.Examples.DynamicSerializer/RabbitMQ.Next.Examples.DynamicSerializer.csproj @@ -2,7 +2,6 @@ Exe - net6.0 false diff --git a/docs/examples/RabbitMQ.Next.Examples.SimpleConsumer/RabbitMQ.Next.Examples.SimpleConsumer.csproj b/docs/examples/RabbitMQ.Next.Examples.SimpleConsumer/RabbitMQ.Next.Examples.SimpleConsumer.csproj index ec05c4fd..7ec2d336 100644 --- a/docs/examples/RabbitMQ.Next.Examples.SimpleConsumer/RabbitMQ.Next.Examples.SimpleConsumer.csproj +++ b/docs/examples/RabbitMQ.Next.Examples.SimpleConsumer/RabbitMQ.Next.Examples.SimpleConsumer.csproj @@ -2,7 +2,6 @@ Exe - net6.0 false diff --git a/docs/examples/RabbitMQ.Next.Examples.SimplePublisher/RabbitMQ.Next.Examples.SimplePublisher.csproj b/docs/examples/RabbitMQ.Next.Examples.SimplePublisher/RabbitMQ.Next.Examples.SimplePublisher.csproj index 78913de8..f8a3edce 100644 --- a/docs/examples/RabbitMQ.Next.Examples.SimplePublisher/RabbitMQ.Next.Examples.SimplePublisher.csproj +++ b/docs/examples/RabbitMQ.Next.Examples.SimplePublisher/RabbitMQ.Next.Examples.SimplePublisher.csproj @@ -2,7 +2,6 @@ Exe - net6.0 false diff --git a/docs/examples/RabbitMQ.Next.Examples.TopologyBuilder/RabbitMQ.Next.Examples.TopologyBuilder.csproj b/docs/examples/RabbitMQ.Next.Examples.TopologyBuilder/RabbitMQ.Next.Examples.TopologyBuilder.csproj index e1902fbb..39cbcea6 100644 --- a/docs/examples/RabbitMQ.Next.Examples.TopologyBuilder/RabbitMQ.Next.Examples.TopologyBuilder.csproj +++ b/docs/examples/RabbitMQ.Next.Examples.TopologyBuilder/RabbitMQ.Next.Examples.TopologyBuilder.csproj @@ -2,7 +2,6 @@ Exe - net6.0 false diff --git a/src/RabbitMQ.Next.Abstractions/RabbitMQ.Next.Abstractions.csproj b/src/RabbitMQ.Next.Abstractions/RabbitMQ.Next.Abstractions.csproj index 7baeab32..e9289f3a 100644 --- a/src/RabbitMQ.Next.Abstractions/RabbitMQ.Next.Abstractions.csproj +++ b/src/RabbitMQ.Next.Abstractions/RabbitMQ.Next.Abstractions.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next RabbitMQ.Next.Abstractions diff --git a/src/RabbitMQ.Next.Consumer.Abstractions/RabbitMQ.Next.Consumer.Abstractions.csproj b/src/RabbitMQ.Next.Consumer.Abstractions/RabbitMQ.Next.Consumer.Abstractions.csproj index 1228e86d..e2f6a778 100644 --- a/src/RabbitMQ.Next.Consumer.Abstractions/RabbitMQ.Next.Consumer.Abstractions.csproj +++ b/src/RabbitMQ.Next.Consumer.Abstractions/RabbitMQ.Next.Consumer.Abstractions.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Consumer RabbitMQ.Next.Consumer.Abstractions diff --git a/src/RabbitMQ.Next.Consumer/RabbitMQ.Next.Consumer.csproj b/src/RabbitMQ.Next.Consumer/RabbitMQ.Next.Consumer.csproj index 6fc13fb1..3191bc61 100644 --- a/src/RabbitMQ.Next.Consumer/RabbitMQ.Next.Consumer.csproj +++ b/src/RabbitMQ.Next.Consumer/RabbitMQ.Next.Consumer.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Consumer diff --git a/src/RabbitMQ.Next.Publisher.Abstractions/RabbitMQ.Next.Publisher.Abstractions.csproj b/src/RabbitMQ.Next.Publisher.Abstractions/RabbitMQ.Next.Publisher.Abstractions.csproj index a0f17a27..c801a30c 100644 --- a/src/RabbitMQ.Next.Publisher.Abstractions/RabbitMQ.Next.Publisher.Abstractions.csproj +++ b/src/RabbitMQ.Next.Publisher.Abstractions/RabbitMQ.Next.Publisher.Abstractions.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Publisher RabbitMQ.Next.Publisher.Abstractions diff --git a/src/RabbitMQ.Next.Publisher.Attributes/RabbitMQ.Next.Publisher.Attributes.csproj b/src/RabbitMQ.Next.Publisher.Attributes/RabbitMQ.Next.Publisher.Attributes.csproj index 4e5b64ab..e69dbce1 100644 --- a/src/RabbitMQ.Next.Publisher.Attributes/RabbitMQ.Next.Publisher.Attributes.csproj +++ b/src/RabbitMQ.Next.Publisher.Attributes/RabbitMQ.Next.Publisher.Attributes.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Publisher.Attributes diff --git a/src/RabbitMQ.Next.Publisher/RabbitMQ.Next.Publisher.csproj b/src/RabbitMQ.Next.Publisher/RabbitMQ.Next.Publisher.csproj index f084a0ed..5eef764a 100644 --- a/src/RabbitMQ.Next.Publisher/RabbitMQ.Next.Publisher.csproj +++ b/src/RabbitMQ.Next.Publisher/RabbitMQ.Next.Publisher.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Publisher diff --git a/src/RabbitMQ.Next.Serialization.Dynamic/RabbitMQ.Next.Serialization.Dynamic.csproj b/src/RabbitMQ.Next.Serialization.Dynamic/RabbitMQ.Next.Serialization.Dynamic.csproj index 78c0a655..93ee36c8 100644 --- a/src/RabbitMQ.Next.Serialization.Dynamic/RabbitMQ.Next.Serialization.Dynamic.csproj +++ b/src/RabbitMQ.Next.Serialization.Dynamic/RabbitMQ.Next.Serialization.Dynamic.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Serialization.Dynamic diff --git a/src/RabbitMQ.Next.Serialization.MessagePack/RabbitMQ.Next.Serialization.MessagePack.csproj b/src/RabbitMQ.Next.Serialization.MessagePack/RabbitMQ.Next.Serialization.MessagePack.csproj index 1b80eb03..a2745934 100644 --- a/src/RabbitMQ.Next.Serialization.MessagePack/RabbitMQ.Next.Serialization.MessagePack.csproj +++ b/src/RabbitMQ.Next.Serialization.MessagePack/RabbitMQ.Next.Serialization.MessagePack.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Serialization.MessagePack diff --git a/src/RabbitMQ.Next.Serialization.NewtonsoftJson/RabbitMQ.Next.Serialization.NewtonsoftJson.csproj b/src/RabbitMQ.Next.Serialization.NewtonsoftJson/RabbitMQ.Next.Serialization.NewtonsoftJson.csproj index 10a69d52..7f0c9bb8 100644 --- a/src/RabbitMQ.Next.Serialization.NewtonsoftJson/RabbitMQ.Next.Serialization.NewtonsoftJson.csproj +++ b/src/RabbitMQ.Next.Serialization.NewtonsoftJson/RabbitMQ.Next.Serialization.NewtonsoftJson.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Serialization.NewtonsoftJson diff --git a/src/RabbitMQ.Next.Serialization.PlainText/RabbitMQ.Next.Serialization.PlainText.csproj b/src/RabbitMQ.Next.Serialization.PlainText/RabbitMQ.Next.Serialization.PlainText.csproj index f892c97f..04ced7c4 100644 --- a/src/RabbitMQ.Next.Serialization.PlainText/RabbitMQ.Next.Serialization.PlainText.csproj +++ b/src/RabbitMQ.Next.Serialization.PlainText/RabbitMQ.Next.Serialization.PlainText.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Serialization.PlainText diff --git a/src/RabbitMQ.Next.Serialization.SystemJson/RabbitMQ.Next.Serialization.SystemJson.csproj b/src/RabbitMQ.Next.Serialization.SystemJson/RabbitMQ.Next.Serialization.SystemJson.csproj index 2780d717..3522270e 100644 --- a/src/RabbitMQ.Next.Serialization.SystemJson/RabbitMQ.Next.Serialization.SystemJson.csproj +++ b/src/RabbitMQ.Next.Serialization.SystemJson/RabbitMQ.Next.Serialization.SystemJson.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.Serialization.SystemJson diff --git a/src/RabbitMQ.Next.TopologyBuilder.Abstractions/RabbitMQ.Next.TopologyBuilder.Abstractions.csproj b/src/RabbitMQ.Next.TopologyBuilder.Abstractions/RabbitMQ.Next.TopologyBuilder.Abstractions.csproj index f86f48b8..640e6ae1 100644 --- a/src/RabbitMQ.Next.TopologyBuilder.Abstractions/RabbitMQ.Next.TopologyBuilder.Abstractions.csproj +++ b/src/RabbitMQ.Next.TopologyBuilder.Abstractions/RabbitMQ.Next.TopologyBuilder.Abstractions.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.TopologyBuilder.Abstractions RabbitMQ.Next.TopologyBuilder diff --git a/src/RabbitMQ.Next.TopologyBuilder/RabbitMQ.Next.TopologyBuilder.csproj b/src/RabbitMQ.Next.TopologyBuilder/RabbitMQ.Next.TopologyBuilder.csproj index 6a84e496..56c0e6f5 100644 --- a/src/RabbitMQ.Next.TopologyBuilder/RabbitMQ.Next.TopologyBuilder.csproj +++ b/src/RabbitMQ.Next.TopologyBuilder/RabbitMQ.Next.TopologyBuilder.csproj @@ -1,7 +1,6 @@ - net6.0 RabbitMQ.Next.TopologyBuilder diff --git a/src/RabbitMQ.Next/Connection.cs b/src/RabbitMQ.Next/Connection.cs index 9faff0ff..f0366799 100644 --- a/src/RabbitMQ.Next/Connection.cs +++ b/src/RabbitMQ.Next/Connection.cs @@ -132,6 +132,7 @@ private void SendLoop() { var heartbeatMemory = new MemoryAccessor(ProtocolConstants.HeartbeatFrame); var socketChannel = this.socketSender.Reader; + do { while (socketChannel.TryRead(out var memory)) @@ -146,19 +147,19 @@ private void SendLoop() } } - var waitResult = socketChannel.WaitToReadAsync().Wait(this.connectionDetails.HeartbeatInterval); - if (waitResult.IsCompleted) + if (socketChannel.WaitToReadAsync().Wait(this.connectionDetails.HeartbeatInterval, out var canRead)) { - if (waitResult.Result) + if (!canRead) { - continue; + return; } - - break; + } + else + { + // wait long enough and nothing was sent, need to send heartbeat frame + this.socket.Send(heartbeatMemory); } - // wait long enough and nothing was sent, need to send heartbeat frame - this.socket.Send(heartbeatMemory); } while (true); } diff --git a/src/RabbitMQ.Next/RabbitMQ.Next.csproj b/src/RabbitMQ.Next/RabbitMQ.Next.csproj index 27d7bfd8..4079a8a1 100644 --- a/src/RabbitMQ.Next/RabbitMQ.Next.csproj +++ b/src/RabbitMQ.Next/RabbitMQ.Next.csproj @@ -1,18 +1,13 @@ - net6.0;net7.0 RabbitMQ.Next - + - - - - diff --git a/src/RabbitMQ.Next/Tasks/TaskExtensions.cs b/src/RabbitMQ.Next/Tasks/TaskExtensions.cs index 9aba8dac..8f474de4 100644 --- a/src/RabbitMQ.Next/Tasks/TaskExtensions.cs +++ b/src/RabbitMQ.Next/Tasks/TaskExtensions.cs @@ -5,11 +5,12 @@ namespace RabbitMQ.Next.Tasks; public static class TaskExtensions { - public static (bool IsCompleted, T Result) Wait(this ValueTask valueTask, TimeSpan? timeout) + public static bool Wait(this ValueTask valueTask, TimeSpan? timeout, out T result) { if (valueTask.IsCompleted) { - return (true, valueTask.Result); + result = valueTask.Result; + return true; } var task = valueTask.AsTask(); @@ -21,9 +22,11 @@ public static (bool IsCompleted, T Result) Wait(this ValueTask valueTask, if (task.Wait(timeoutMs)) { - return (true, task.Result); + result = task.Result; + return true; } - return (false, default); + result = default; + return false; } } diff --git a/tests/RabbitMQ.Next.Tests/RabbitMQ.Next.Tests.csproj b/tests/RabbitMQ.Next.Tests/RabbitMQ.Next.Tests.csproj index 77662731..672d14f6 100644 --- a/tests/RabbitMQ.Next.Tests/RabbitMQ.Next.Tests.csproj +++ b/tests/RabbitMQ.Next.Tests/RabbitMQ.Next.Tests.csproj @@ -1,7 +1,6 @@ - net6.0;net7.0 false