diff --git a/GitVersion.yml b/GitVersion.yml
index e8a3c42..a4e2731 100644
--- a/GitVersion.yml
+++ b/GitVersion.yml
@@ -56,4 +56,4 @@ branches:
ignore:
sha: []
merge-message-formats: {}
-next-version: 0.1.15
+next-version: 0.1.16
diff --git a/doc/dependency_decisions.yml b/doc/dependency_decisions.yml
index d0bb892..9ff6628 100644
--- a/doc/dependency_decisions.yml
+++ b/doc/dependency_decisions.yml
@@ -32,14 +32,14 @@
- :who: mocsharp
:why: MIT (https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt)
:versions:
- - 6.0.10
+ - 6.0.11
:when: 2022-08-29 18:11:22.090772006 Z
- - :approve
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions
- :who: mocsharp
:why: MIT (https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt)
:versions:
- - 6.0.10
+ - 6.0.11
:when: 2022-08-29 18:11:22.090772006 Z
- - :approve
- Microsoft.Extensions.Configuration
@@ -158,7 +158,7 @@
- :who: mocsharp
:why: MIT (https://github.com/dotnet/runtime/raw/main/LICENSE.TXT)
:versions:
- - 6.0.2
+ - 6.0.3
:when: 2022-08-16 21:39:44.471693654 Z
- - :approve
- Microsoft.Extensions.Logging.Configuration
@@ -277,7 +277,7 @@
- :who: mocsharp
:why: MIT (https://github.com/JamesNK/Newtonsoft.Json/raw/master/LICENSE.md)
:versions:
- - 13.0.1
+ - 13.0.2
:when: 2022-08-16 21:39:51.628833960 Z
- - :approve
- NuGet.Frameworks
@@ -406,19 +406,26 @@
- 4.3.0
:when: 2022-08-16 21:39:59.280855676 Z
- - :approve
- - System.IO.Abstractions
+ - TestableIO.System.IO.Abstractions
- :who: mocsharp
:why: MIT (https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE)
:versions:
- - 17.2.3
+ - 18.0.1
:when: 2022-08-16 21:39:59.728481602 Z
- - :approve
- - System.IO.Abstractions.TestingHelpers
+ - TestableIO.System.IO.Abstractions.TestingHelpers
- :who: mocsharp
:why: MIT (https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE)
:versions:
- - 17.2.3
+ - 18.0.1
:when: 2022-08-16 21:40:00.150566731 Z
+- - :approve
+ - TestableIO.System.IO.Abstractions.Wrappers
+ - :who: mocsharp
+ :why: MIT (https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE)
+ :versions:
+ - 18.0.1
+ :when: 2022-11-30 21:40:00.150566731 Z
- - :approve
- System.IO.Compression
- :who: mocsharp
diff --git a/src/Messaging/Monai.Deploy.Messaging.csproj b/src/Messaging/Monai.Deploy.Messaging.csproj
index 3a04b76..8884ac4 100644
--- a/src/Messaging/Monai.Deploy.Messaging.csproj
+++ b/src/Messaging/Monai.Deploy.Messaging.csproj
@@ -76,10 +76,11 @@
-
+
-
+
-
+
+
\ No newline at end of file
diff --git a/src/Messaging/Tests/Monai.Deploy.Messaging.Tests.csproj b/src/Messaging/Tests/Monai.Deploy.Messaging.Tests.csproj
index 2c8769f..fc1127d 100644
--- a/src/Messaging/Tests/Monai.Deploy.Messaging.Tests.csproj
+++ b/src/Messaging/Tests/Monai.Deploy.Messaging.Tests.csproj
@@ -34,7 +34,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Plugins/RabbitMQ/ChannelType.cs b/src/Plugins/RabbitMQ/ChannelType.cs
new file mode 100644
index 0000000..6cc735d
--- /dev/null
+++ b/src/Plugins/RabbitMQ/ChannelType.cs
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2021-2022 MONAI Consortium
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Monai.Deploy.Messaging.RabbitMQ
+{
+ public enum ChannelType
+ {
+ Subscriber,
+ Publisher
+ }
+}
diff --git a/src/Plugins/RabbitMQ/Factory/IRabbitMQConnectionFactory.cs b/src/Plugins/RabbitMQ/Factory/IRabbitMQConnectionFactory.cs
index 6ea0358..cda59ee 100644
--- a/src/Plugins/RabbitMQ/Factory/IRabbitMQConnectionFactory.cs
+++ b/src/Plugins/RabbitMQ/Factory/IRabbitMQConnectionFactory.cs
@@ -32,6 +32,6 @@ public interface IRabbitMQConnectionFactory
/// Encrypt communication
/// Port Number
/// Instance of .
- IModel? CreateChannel( string hostName, string username, string password, string virtualHost, string useSSL, string portNumber);
+ IModel? CreateChannel( ChannelType type, string hostName, string username, string password, string virtualHost, string useSSL, string portNumber);
}
}
diff --git a/src/Plugins/RabbitMQ/Factory/RabbitMqConnectionFactory.cs b/src/Plugins/RabbitMQ/Factory/RabbitMqConnectionFactory.cs
index 4559800..de6edaa 100644
--- a/src/Plugins/RabbitMQ/Factory/RabbitMqConnectionFactory.cs
+++ b/src/Plugins/RabbitMQ/Factory/RabbitMqConnectionFactory.cs
@@ -41,17 +41,17 @@ public RabbitMQConnectionFactory(ILogger logger)
}
- public IModel CreateChannel(string hostName, string username, string password, string virtualHost, string useSSL, string portNumber)
+ public IModel CreateChannel(ChannelType type, string hostName, string username, string password, string virtualHost, string useSSL, string portNumber)
{
Guard.Against.NullOrWhiteSpace(hostName);
Guard.Against.NullOrWhiteSpace(username);
Guard.Against.NullOrWhiteSpace(password);
Guard.Against.NullOrWhiteSpace(virtualHost);
- var key = $"{hostName}{username}{HashPassword(password)}{virtualHost}";
+ var key = $"{type}{hostName}{username}{HashPassword(password)}{virtualHost}";
var connection = _connections.AddOrUpdate(key,
- x => MakeConnection(hostName, username, password, virtualHost, key, useSSL, portNumber),
+ x => MakeConnection(type, hostName, username, password, virtualHost, key, useSSL, portNumber),
(updateKey, updateConnection) =>
{
// If connection to RMQ is lost and:
@@ -62,13 +62,13 @@ public IModel CreateChannel(string hostName, string username, string password, s
{
if (updateConnection.model.IsClosed)
{
- updateConnection.model = MakeChannel(updateConnection.connection, key);
+ updateConnection.model = MakeChannel(type, updateConnection.connection, key);
}
return updateConnection;
}
else
{
- return MakeConnection(hostName, username, password, virtualHost, key, useSSL, portNumber);
+ return MakeConnection(type, hostName, username, password, virtualHost, key, useSSL, portNumber);
}
});
@@ -87,18 +87,22 @@ private void OnException(CallbackExceptionEventArgs args, IConnection value, str
}
- private (IConnection, IModel) MakeConnection(string hostName, string username, string password, string virtualHost, string key, string useSSL, string portNumber)
+ private (IConnection, IModel) MakeConnection(ChannelType type, string hostName, string username, string password, string virtualHost, string key, string useSSL, string portNumber)
{
var connection = CreateConnectionOnly(hostName, username, password, virtualHost, key, useSSL, portNumber);
- var model = MakeChannel(connection, key);
+ var model = MakeChannel(type, connection, key);
return (connection, model);
}
- private IModel MakeChannel(IConnection connection, string key)
+ private IModel MakeChannel(ChannelType type, IConnection connection, string key)
{
var model = connection.CreateModel();
model.CallbackException += (sender, args) => OnException(args, connection, key);
model.ModelShutdown += (sender, args) => ConnectionShutdown(args, connection, key);
+ if (type == ChannelType.Publisher)
+ {
+ model.ConfirmSelect();
+ }
return model;
}
diff --git a/src/Plugins/RabbitMQ/Publisher/RabbitMqMessagePublisherService.cs b/src/Plugins/RabbitMQ/Publisher/RabbitMqMessagePublisherService.cs
index f78369f..7ded148 100644
--- a/src/Plugins/RabbitMQ/Publisher/RabbitMqMessagePublisherService.cs
+++ b/src/Plugins/RabbitMQ/Publisher/RabbitMqMessagePublisherService.cs
@@ -108,12 +108,11 @@ public Task Publish(string topic, Message message)
_logger.PublshingRabbitMQ(_endpoint, _virtualHost, _exchange, topic);
- var channel = _rabbitMqConnectionFactory.CreateChannel(_endpoint, _username, _password, _virtualHost, _useSSL, _portNumber);
+ var channel = _rabbitMqConnectionFactory.CreateChannel(ChannelType.Publisher, _endpoint, _username, _password, _virtualHost, _useSSL, _portNumber);
if (channel is null) { throw new NullReferenceException("RabbitMq channel returned null"); }
channel.ExchangeDeclare(_exchange, ExchangeType.Topic, durable: true, autoDelete: false);
- channel.ConfirmSelect();
var properties = channel.CreateBasicProperties();
properties.Persistent = true;
diff --git a/src/Plugins/RabbitMQ/RabbitMQHealthCheck.cs b/src/Plugins/RabbitMQ/RabbitMQHealthCheck.cs
index 3e1288c..ee32f6a 100644
--- a/src/Plugins/RabbitMQ/RabbitMQHealthCheck.cs
+++ b/src/Plugins/RabbitMQ/RabbitMQHealthCheck.cs
@@ -47,6 +47,7 @@ public RabbitMQHealthCheck(
try
{
var channel = _connectionFactory.CreateChannel(
+ ChannelType.Subscriber,
_options[ConfigurationKeys.EndPoint],
_options[ConfigurationKeys.Username],
_options[ConfigurationKeys.Password],
diff --git a/src/Plugins/RabbitMQ/Subscriber/RabbitMqMessageSubscriberService.cs b/src/Plugins/RabbitMQ/Subscriber/RabbitMqMessageSubscriberService.cs
index d3e389b..fa76617 100644
--- a/src/Plugins/RabbitMQ/Subscriber/RabbitMqMessageSubscriberService.cs
+++ b/src/Plugins/RabbitMQ/Subscriber/RabbitMqMessageSubscriberService.cs
@@ -108,7 +108,7 @@ private void CreateChannel()
.Execute(() =>
{
_logger.ConnectingToRabbitMQ(Name, _endpoint, _virtualHost);
- _channel = _rabbitMqConnectionFactory.CreateChannel(_endpoint, _username, _password, _virtualHost, _useSSL, _portNumber);
+ _channel = _rabbitMqConnectionFactory.CreateChannel(ChannelType.Subscriber, _endpoint, _username, _password, _virtualHost, _useSSL, _portNumber);
_channel.ExchangeDeclare(_exchange, ExchangeType.Topic, durable: true, autoDelete: false);
_channel.ExchangeDeclare(_deadLetterExchange, ExchangeType.Topic, durable: true, autoDelete: false);
_channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);
diff --git a/src/Plugins/RabbitMQ/Tests/Monai.Deploy.Messaging.RabbitMQ.Tests.csproj b/src/Plugins/RabbitMQ/Tests/Monai.Deploy.Messaging.RabbitMQ.Tests.csproj
index 1e538f2..4b74f9b 100644
--- a/src/Plugins/RabbitMQ/Tests/Monai.Deploy.Messaging.RabbitMQ.Tests.csproj
+++ b/src/Plugins/RabbitMQ/Tests/Monai.Deploy.Messaging.RabbitMQ.Tests.csproj
@@ -37,7 +37,7 @@
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/Plugins/RabbitMQ/Tests/RabbitMQHealthCheckTest.cs b/src/Plugins/RabbitMQ/Tests/RabbitMQHealthCheckTest.cs
index 8ada62d..f4c1829 100644
--- a/src/Plugins/RabbitMQ/Tests/RabbitMQHealthCheckTest.cs
+++ b/src/Plugins/RabbitMQ/Tests/RabbitMQHealthCheckTest.cs
@@ -42,7 +42,7 @@ public RabbitMQHealthCheckTest()
[Fact]
public async Task CheckHealthAsync_WhenFailed_ReturnUnhealthy()
{
- _connectionFactory.Setup(p => p.CreateChannel(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ _connectionFactory.Setup(p => p.CreateChannel(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
.Throws(new Exception("error"));
var healthCheck = new RabbitMQHealthCheck(_connectionFactory.Object, _options, _logger.Object, (d) => { });
@@ -58,7 +58,7 @@ public async Task CheckHealthAsync_WhenSucceeds_ReturnHealthy()
{
var channel = new Mock();
channel.Setup(p => p.Close());
- _connectionFactory.Setup(p => p.CreateChannel(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ _connectionFactory.Setup(p => p.CreateChannel(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
.Returns(channel.Object);
var healthCheck = new RabbitMQHealthCheck(_connectionFactory.Object, _options, _logger.Object, (d) => { });
var results = await healthCheck.CheckHealthAsync(new HealthCheckContext()).ConfigureAwait(false);
diff --git a/src/Plugins/RabbitMQ/Tests/RabbitMqMessagePublisherServiceTest.cs b/src/Plugins/RabbitMQ/Tests/RabbitMqMessagePublisherServiceTest.cs
index b6a7d5e..6df8927 100644
--- a/src/Plugins/RabbitMQ/Tests/RabbitMqMessagePublisherServiceTest.cs
+++ b/src/Plugins/RabbitMQ/Tests/RabbitMqMessagePublisherServiceTest.cs
@@ -31,7 +31,7 @@ public class RabbitMQMessagePublisherServiceTest
private readonly Mock> _logger;
private readonly Mock _connectionFactory;
private readonly Mock _model;
- private static readonly object mutex = new();
+ private static readonly object Mutex = new();
public RabbitMQMessagePublisherServiceTest()
{
_options = Options.Create(new MessageBrokerServiceConfiguration());
@@ -39,7 +39,7 @@ public RabbitMQMessagePublisherServiceTest()
_connectionFactory = new Mock();
_model = new Mock();
- _connectionFactory.Setup(p => p.CreateChannel(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ _connectionFactory.Setup(p => p.CreateChannel(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
.Returns(_model.Object);
}
@@ -117,7 +117,7 @@ public async Task IntegrationTestRabbitPublish()
var pubService = new RabbitMQMessagePublisherService(Options.Create(options), new Mock>().Object, connectionFactory);
var subService = new RabbitMQMessageSubscriberService(Options.Create(options), new Mock>().Object, connectionFactory);
- var count = 10000;
+ var count = 100;
var subRecievedCount = 0;
var skipped = 0;
@@ -139,7 +139,7 @@ await Task.Run(async () =>
try
{
subService.Acknowledge(args.Message);
- lock (mutex)
+ lock (Mutex)
subRecievedCount++;
}
catch (Exception)
@@ -163,7 +163,7 @@ await Task.Run(async () =>
Assert.Equal(HealthStatus.Healthy, result1.Status);
}
- await Task.Delay(5000);
+ await Task.Delay(15000);
result1 = await hc1.CheckHealthAsync(new HealthCheckContext());
Assert.Equal(HealthStatus.Healthy, result1.Status);
@@ -171,7 +171,7 @@ await Task.Run(async () =>
result1 = await hc2.CheckHealthAsync(new HealthCheckContext());
Assert.Equal(HealthStatus.Healthy, result1.Status);
- Assert.Equal((count * 2) -skipped, subRecievedCount);
+ Assert.Equal((count * 2) - skipped, subRecievedCount);
}
private async Task PublishMessage(RabbitMQMessagePublisherService pubService, string topic, Message message)
diff --git a/src/Plugins/RabbitMQ/Tests/RabbitMqMessageSubscriberServiceTest.cs b/src/Plugins/RabbitMQ/Tests/RabbitMqMessageSubscriberServiceTest.cs
index d241323..76e83a5 100644
--- a/src/Plugins/RabbitMQ/Tests/RabbitMqMessageSubscriberServiceTest.cs
+++ b/src/Plugins/RabbitMQ/Tests/RabbitMqMessageSubscriberServiceTest.cs
@@ -40,7 +40,7 @@ public RabbitMQMessageSubscriberServiceTest()
_connectionFactory = new Mock();
_model = new Mock();
- _connectionFactory.Setup(p => p.CreateChannel(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
+ _connectionFactory.Setup(p => p.CreateChannel(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()))
.Returns(_model.Object);
}
diff --git a/third-party-licenses.md b/third-party-licenses.md
index af21e0c..83f195d 100644
--- a/third-party-licenses.md
+++ b/third-party-licenses.md
@@ -619,14 +619,14 @@ SOFTWARE.
-Microsoft.Extensions.Diagnostics.HealthChecks 6.0.10
+Microsoft.Extensions.Diagnostics.HealthChecks 6.0.11
## Microsoft.Extensions.Diagnostics.HealthChecks
-- Version: 6.0.10
+- Version: 6.0.11
- Authors: Microsoft
- Project URL: https://asp.net/
-- Source: [NuGet](https://www.nuget.org/packages/Microsoft.Extensions.Diagnostics.HealthChecks/6.0.10)
+- Source: [NuGet](https://www.nuget.org/packages/Microsoft.Extensions.Diagnostics.HealthChecks/6.0.11)
- License: [MIT](https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt)
@@ -660,14 +660,14 @@ SOFTWARE.
-Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions 6.0.10
+Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions 6.0.11
## Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions
-- Version: 6.0.10
+- Version: 6.0.11
- Authors: Microsoft
- Project URL: https://asp.net/
-- Source: [NuGet](https://www.nuget.org/packages/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions/6.0.10)
+- Source: [NuGet](https://www.nuget.org/packages/Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions/6.0.11)
- License: [MIT](https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt)
@@ -947,14 +947,14 @@ SOFTWARE.
-Microsoft.Extensions.Logging.Abstractions 6.0.2
+Microsoft.Extensions.Logging.Abstractions 6.0.3
## Microsoft.Extensions.Logging.Abstractions
-- Version: 6.0.2
+- Version: 6.0.3
- Authors: Microsoft
- Project URL: https://dot.net/
-- Source: [NuGet](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Abstractions/6.0.2)
+- Source: [NuGet](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Abstractions/6.0.3)
- License: [MIT](https://github.com/dotnet/runtime/raw/main/LICENSE.TXT)
@@ -2277,14 +2277,14 @@ consequential or other damages.
-Newtonsoft.Json 13.0.1
+Newtonsoft.Json 13.0.2
## Newtonsoft.Json
-- Version: 13.0.1
+- Version: 13.0.2
- Authors: James Newton-King
- Project URL: https://www.newtonsoft.com/json
-- Source: [NuGet](https://www.nuget.org/packages/Newtonsoft.Json/13.0.1)
+- Source: [NuGet](https://www.nuget.org/packages/Newtonsoft.Json/13.0.2)
- License: [MIT](https://github.com/JamesNK/Newtonsoft.Json/raw/master/LICENSE.md)
@@ -5165,15 +5165,15 @@ consequential or other damages.
-System.IO.Abstractions 17.2.3
+TestableIO.System.IO.Abstractions 18.0.1
-## System.IO.Abstractions
+## TestableIO.System.IO.Abstractions
-- Version: 17.2.3
+- Version: 18.0.1
- Authors: Tatham Oddie & friends
-- Project URL: https://github.com/TestableIO/System.IO.Abstractions
-- Source: [NuGet](https://www.nuget.org/packages/System.IO.Abstractions/17.2.3)
-- License: [MIT](https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE)
+- Project URL: https://github.com/TestableIO/TestableIO.System.IO.Abstractions
+- Source: [NuGet](https://www.nuget.org/packages/TestableIO.System.IO.Abstractions/18.0.1)
+- License: [MIT](https://github.com/TestableIO/TestableIO.System.IO.Abstractions/raw/main/LICENSE)
```
@@ -5206,15 +5206,15 @@ SOFTWARE.
-System.IO.Abstractions.TestingHelpers 17.2.3
+TestableIO.System.IO.Abstractions.TestingHelpers 18.0.1
-## System.IO.Abstractions.TestingHelpers
+## TestableIO.System.IO.Abstractions.TestingHelpers
-- Version: 17.2.3
+- Version: 18.0.1
- Authors: Tatham Oddie & friends
-- Project URL: https://github.com/TestableIO/System.IO.Abstractions
-- Source: [NuGet](https://www.nuget.org/packages/System.IO.Abstractions.TestingHelpers/17.2.3)
-- License: [MIT](https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE)
+- Project URL: https://github.com/TestableIO/TestableIO.System.IO.Abstractions
+- Source: [NuGet](https://www.nuget.org/packages/TestableIO.System.IO.Abstractions.TestingHelpers/18.0.1)
+- License: [MIT](https://github.com/TestableIO/TestableIO.System.IO.Abstractions/raw/main/LICENSE)
```