diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index d1199ce1f6..5d85b8b2b3 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -16,7 +16,7 @@
-
+
@@ -27,25 +27,24 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -58,6 +57,7 @@
+
diff --git a/src/ProjectReferences.Transports.props b/src/ProjectReferences.Transports.props
index ecabdb9a97..71ce167f9d 100644
--- a/src/ProjectReferences.Transports.props
+++ b/src/ProjectReferences.Transports.props
@@ -4,7 +4,7 @@
-
+
diff --git a/src/ServiceControl.AcceptanceTesting/ScenarioWithEndpointBehaviorExtensions.cs b/src/ServiceControl.AcceptanceTesting/ScenarioWithEndpointBehaviorExtensions.cs
index fa22461600..16b3355faa 100644
--- a/src/ServiceControl.AcceptanceTesting/ScenarioWithEndpointBehaviorExtensions.cs
+++ b/src/ServiceControl.AcceptanceTesting/ScenarioWithEndpointBehaviorExtensions.cs
@@ -64,7 +64,7 @@ public IScenarioWithEndpointBehavior Done(Func doneCri
// If sequence is done but test is not finished, small delay to avoid tight loop check
await Task.Delay(250);
- // If sequence is not finished immediately return false, since each step will enforce delays
+ // If sequence is not finished immediately return false, since each step will enforce delays
return false;
});
}
@@ -127,7 +127,7 @@ public override Task ComponentsStarted(CancellationToken cancellationToken = def
return Task.CompletedTask;
}
- public override async Task Stop()
+ public override async Task Stop(CancellationToken cancellationToken = default)
{
if (checkTask == null)
{
diff --git a/src/ServiceControl.AcceptanceTesting/StaticContextAppender.cs b/src/ServiceControl.AcceptanceTesting/StaticContextAppender.cs
deleted file mode 100644
index b1120c5a42..0000000000
--- a/src/ServiceControl.AcceptanceTesting/StaticContextAppender.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-namespace ServiceControl.AcceptanceTesting
-{
- using System;
- using System.Diagnostics;
- using System.Reflection;
- using NServiceBus.AcceptanceTesting;
- using NServiceBus.Logging;
-
- class StaticContextAppender : ILog
- {
- public bool IsDebugEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Debug;
- public bool IsInfoEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Info;
- public bool IsWarnEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Warn;
- public bool IsErrorEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Error;
- public bool IsFatalEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Fatal;
-
-
- public void Debug(string message)
- {
- Log(message, LogLevel.Debug);
- }
-
- public void Debug(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Debug);
- }
-
- public void DebugFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Debug);
- }
-
- public void Info(string message)
- {
- Log(message, LogLevel.Info);
- }
-
-
- public void Info(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Info);
- }
-
- public void InfoFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Info);
- }
-
- public void Warn(string message)
- {
- Log(message, LogLevel.Warn);
- }
-
- public void Warn(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Warn);
- }
-
- public void WarnFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Warn);
- }
-
- public void Error(string message)
- {
- Log(message, LogLevel.Error);
- }
-
- public void Error(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Error);
- }
-
- public void ErrorFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Error);
- }
-
- public void Fatal(string message)
- {
- Log(message, LogLevel.Fatal);
- }
-
- public void Fatal(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Fatal);
- }
-
- public void FatalFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Fatal);
- }
-
- void Log(string message, LogLevel messageSeverity)
- {
- if (StaticLoggerFactory.CurrentContext.LogLevel > messageSeverity)
- {
- return;
- }
-
- Trace.WriteLine(message);
- StaticLoggerFactory.CurrentContext.Logs.Enqueue(new ScenarioContext.LogItem
- {
- Endpoint = (string)typeof(ScenarioContext).GetProperty("CurrentEndpoint", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(StaticLoggerFactory.CurrentContext),
- Level = messageSeverity,
- Message = message
- });
- }
- }
-}
\ No newline at end of file
diff --git a/src/ServiceControl.AcceptanceTesting/StaticLoggerFactory.cs b/src/ServiceControl.AcceptanceTesting/StaticLoggerFactory.cs
deleted file mode 100644
index bd2c0a8f10..0000000000
--- a/src/ServiceControl.AcceptanceTesting/StaticLoggerFactory.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-namespace ServiceControl.AcceptanceTesting
-{
- using System;
- using NServiceBus.AcceptanceTesting;
- using NServiceBus.Logging;
-
- public class StaticLoggerFactory : ILoggerFactory
- {
- public StaticLoggerFactory(ScenarioContext currentContext)
- {
- CurrentContext = currentContext;
- }
-
- public ILog GetLogger(Type type)
- {
- return GetLogger(type.FullName);
- }
-
- public ILog GetLogger(string name)
- {
- return new StaticContextAppender();
- }
-
- public static ScenarioContext CurrentContext;
- }
-}
\ No newline at end of file
diff --git a/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs b/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs
index 0af5dcd108..bcb3af7ca6 100644
--- a/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs
+++ b/src/ServiceControl.AcceptanceTests/TestSupport/AcceptanceTest.cs
@@ -38,12 +38,6 @@ protected AcceptanceTest()
public Settings Settings => serviceControlRunnerBehavior.Settings;
public Func HttpMessageHandlerFactory => serviceControlRunnerBehavior.HttpMessageHandlerFactory;
- [OneTimeSetUp]
- public static void OneTimeSetup()
- {
- Scenario.GetLoggerFactory = ctx => new StaticLoggerFactory(ctx);
- }
-
[SetUp]
public void Setup()
{
diff --git a/src/ServiceControl.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs b/src/ServiceControl.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
index 7c655e25ef..88da96fa2b 100644
--- a/src/ServiceControl.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
+++ b/src/ServiceControl.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
@@ -4,6 +4,7 @@
using System.IO;
using System.Net.Http;
using System.Text.Json;
+ using System.Threading;
using System.Threading.Tasks;
using AcceptanceTesting;
using Infrastructure.DomainEvents;
@@ -157,7 +158,7 @@ async Task InitializeServiceControl(ScenarioContext context)
host = hostBuilder.Build();
host.UseServiceControl();
- await host.StartServiceControl();
+ await host.StartAsync();
DomainEvents = host.Services.GetRequiredService();
// Bring this back and look into the base address of the client
HttpClient = host.GetTestServer().CreateClient();
@@ -165,11 +166,11 @@ async Task InitializeServiceControl(ScenarioContext context)
}
}
- public override async Task Stop()
+ public override async Task Stop(CancellationToken cancellationToken = default)
{
using (new DiagnosticTimer($"Test TearDown for {instanceName}"))
{
- await host.StopAsync();
+ await host.StopAsync(cancellationToken);
HttpClient.Dispose();
await host.DisposeAsync();
await persistenceToUse.Cleanup();
diff --git a/src/ServiceControl.Audit.AcceptanceTests/AcceptanceTest.cs b/src/ServiceControl.Audit.AcceptanceTests/AcceptanceTest.cs
index cb0c61ed62..1aac200db2 100644
--- a/src/ServiceControl.Audit.AcceptanceTests/AcceptanceTest.cs
+++ b/src/ServiceControl.Audit.AcceptanceTests/AcceptanceTest.cs
@@ -36,9 +36,6 @@ protected AcceptanceTest()
// TODO Check why this is necessary and if it can be removed
protected IServiceProvider ServiceProvider => serviceControlRunnerBehavior.ServiceProvider;
- [OneTimeSetUp]
- public static void OneTimeSetup() => Scenario.GetLoggerFactory = ctx => new StaticLoggerFactory(ctx);
-
[SetUp]
public void Setup()
{
diff --git a/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs b/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
index df263aa1cd..341fb9f244 100644
--- a/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
+++ b/src/ServiceControl.Audit.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
@@ -6,6 +6,7 @@ namespace ServiceControl.Audit.AcceptanceTests.TestSupport
using System.IO;
using System.Net.Http;
using System.Text.Json;
+ using System.Threading;
using System.Threading.Tasks;
using AcceptanceTesting;
using Auditing;
@@ -179,11 +180,11 @@ async Task InitializeServiceControl(ScenarioContext context)
}
}
- public override async Task Stop()
+ public override async Task Stop(CancellationToken cancellationToken = default)
{
using (new DiagnosticTimer($"Test TearDown for {instanceName}"))
{
- await host.StopAsync();
+ await host.StopAsync(cancellationToken);
HttpClient.Dispose();
await host.DisposeAsync();
}
diff --git a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/ImportFailedAuditsCommand.cs b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/ImportFailedAuditsCommand.cs
index 7ad87ed42f..6225f54480 100644
--- a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/ImportFailedAuditsCommand.cs
+++ b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/ImportFailedAuditsCommand.cs
@@ -28,10 +28,9 @@ public override async Task Execute(HostArguments args, Settings settings)
tokenSource.Cancel();
return Task.CompletedTask;
}, settings, endpointConfiguration, loggingSettings);
- using var app = hostBuilder.Build();
+ using var app = hostBuilder.Build();
app.UseServiceControlAudit();
-
await app.StartAsync(tokenSource.Token);
var importer = app.Services.GetRequiredService();
diff --git a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/RunCommand.cs b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/RunCommand.cs
index c3d5380255..373ed0d659 100644
--- a/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/RunCommand.cs
+++ b/src/ServiceControl.Audit/Infrastructure/Hosting/Commands/RunCommand.cs
@@ -22,8 +22,7 @@ public override async Task Execute(HostArguments args, Settings settings)
return Task.CompletedTask;
}, settings, endpointConfiguration, loggingSettings);
- using var app = hostBuilder.Build();
-
+ var app = hostBuilder.Build();
app.UseServiceControlAudit();
await app.RunAsync();
}
diff --git a/src/ServiceControl.Audit/WebApplicationBuilderExtension.cs b/src/ServiceControl.Audit/WebApplicationBuilderExtension.cs
index 89b8f38570..c7009951e5 100644
--- a/src/ServiceControl.Audit/WebApplicationBuilderExtension.cs
+++ b/src/ServiceControl.Audit/WebApplicationBuilderExtension.cs
@@ -82,13 +82,9 @@ static class WebApplicationBuilderExtension
services.AddMetrics(settings.PrintMetrics);
services.AddPersistence(persistenceSettings, persistenceConfiguration);
- builder.Host.UseNServiceBus(_ =>
- {
- NServiceBusFactory.Configure(settings, transportCustomization, transportSettings, loggingSettings,
- onCriticalError, configuration);
- return configuration;
- });
+ NServiceBusFactory.Configure(settings, transportCustomization, transportSettings, loggingSettings, onCriticalError, configuration);
+ builder.UseNServiceBus(configuration);
// Configure after the NServiceBus hosted service to ensure NServiceBus is already started
if (settings.IngestAuditMessages)
diff --git a/src/ServiceControl.Config.Tests/AddInstance/AddMonitoringInstance/ConnectionString.cs b/src/ServiceControl.Config.Tests/AddInstance/AddMonitoringInstance/ConnectionString.cs
index e01a5c5168..44d1256337 100644
--- a/src/ServiceControl.Config.Tests/AddInstance/AddMonitoringInstance/ConnectionString.cs
+++ b/src/ServiceControl.Config.Tests/AddInstance/AddMonitoringInstance/ConnectionString.cs
@@ -41,39 +41,38 @@ public static MonitoringAddViewModel When_no_transport_is_selected(this Monitori
class AddMonitoringConnectionStringsTests
{
- // TODO uncomment tests when MSMQ is added back
- //[Test]
- //public void MSMQ_transport_is_selected()
- //{
- // var viewModel = Given_a_monitoring_instance()
- // .When_MSQMQ_transport_is_selected();
-
- // Assert.IsFalse(viewModel.ShowConnectionString);
- // Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
- // Assert.IsEmpty(viewModel.SampleConnectionString);
- // Assert.IsNull(viewModel.TransportWarning);
- //}
-
- //[TestAllTransportsExcept("MSMQ")]
- //public void Non_MSMQ_transport_is_selected(string transportInfoName)
- //{
- // var viewModel = Given_a_monitoring_instance()
- // .When_a_transport_is_selected(transportInfoName);
-
- // Assert.IsTrue(viewModel.ShowConnectionString);
- // StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
- // Assert.IsNotEmpty(viewModel.SampleConnectionString);
-
- // if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
- // {
- // Assert.IsNotNull(viewModel.TransportWarning);
- // Assert.IsNotEmpty(viewModel.TransportWarning);
- // }
- // else
- // {
- // Assert.IsNull(viewModel.TransportWarning);
- // }
- //}
+ [Test]
+ public void MSMQ_transport_is_selected()
+ {
+ var viewModel = Given_a_monitoring_instance()
+ .When_MSQMQ_transport_is_selected();
+
+ Assert.IsFalse(viewModel.ShowConnectionString);
+ Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
+ Assert.IsEmpty(viewModel.SampleConnectionString);
+ Assert.IsNull(viewModel.TransportWarning);
+ }
+
+ [TestAllTransportsExcept("MSMQ")]
+ public void Non_MSMQ_transport_is_selected(string transportInfoName)
+ {
+ var viewModel = Given_a_monitoring_instance()
+ .When_a_transport_is_selected(transportInfoName);
+
+ Assert.IsTrue(viewModel.ShowConnectionString);
+ StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
+ Assert.IsNotEmpty(viewModel.SampleConnectionString);
+
+ if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
+ {
+ Assert.IsNotNull(viewModel.TransportWarning);
+ Assert.IsNotEmpty(viewModel.TransportWarning);
+ }
+ else
+ {
+ Assert.IsNull(viewModel.TransportWarning);
+ }
+ }
[Test]
public void Screen_Loaded()
diff --git a/src/ServiceControl.Config.Tests/AddInstance/ConnectionString.cs b/src/ServiceControl.Config.Tests/AddInstance/ConnectionString.cs
index 62b1064b1c..1930e3e80b 100644
--- a/src/ServiceControl.Config.Tests/AddInstance/ConnectionString.cs
+++ b/src/ServiceControl.Config.Tests/AddInstance/ConnectionString.cs
@@ -41,39 +41,38 @@ public static ServiceControlAddViewModel When_no_transport_is_selected(this Serv
class AddConnectionStringsTests
{
- // TODO uncomment tests when MSMQ is added back
- //[Test]
- //public void MSMQ_transport_is_selected()
- //{
- // var viewModel = Given_a_service_control_instance()
- // .When_MSQMQ_transport_is_selected();
-
- // Assert.IsFalse(viewModel.ShowConnectionString);
- // Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
- // Assert.IsEmpty(viewModel.SampleConnectionString);
- // Assert.IsNull(viewModel.TransportWarning);
- //}
-
- //[TestAllTransportsExcept("MSMQ")]
- //public void Non_MSMQ_transport_is_selected(string transportInfoName)
- //{
- // var viewModel = Given_a_service_control_instance()
- // .When_a_transport_is_selected(transportInfoName);
-
- // Assert.IsTrue(viewModel.ShowConnectionString);
- // StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
- // Assert.IsNotEmpty(viewModel.SampleConnectionString);
-
- // if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
- // {
- // Assert.IsNotNull(viewModel.TransportWarning);
- // Assert.IsNotEmpty(viewModel.TransportWarning);
- // }
- // else
- // {
- // Assert.IsNull(viewModel.TransportWarning);
- // }
- //}
+ [Test]
+ public void MSMQ_transport_is_selected()
+ {
+ var viewModel = Given_a_service_control_instance()
+ .When_MSQMQ_transport_is_selected();
+
+ Assert.IsFalse(viewModel.ShowConnectionString);
+ Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
+ Assert.IsEmpty(viewModel.SampleConnectionString);
+ Assert.IsNull(viewModel.TransportWarning);
+ }
+
+ [TestAllTransportsExcept("MSMQ")]
+ public void Non_MSMQ_transport_is_selected(string transportInfoName)
+ {
+ var viewModel = Given_a_service_control_instance()
+ .When_a_transport_is_selected(transportInfoName);
+
+ Assert.IsTrue(viewModel.ShowConnectionString);
+ StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
+ Assert.IsNotEmpty(viewModel.SampleConnectionString);
+
+ if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
+ {
+ Assert.IsNotNull(viewModel.TransportWarning);
+ Assert.IsNotEmpty(viewModel.TransportWarning);
+ }
+ else
+ {
+ Assert.IsNull(viewModel.TransportWarning);
+ }
+ }
[Test]
public void Screen_Loaded()
diff --git a/src/ServiceControl.Config.Tests/EditInstance/EditAuditInstance/ConnectionString.cs b/src/ServiceControl.Config.Tests/EditInstance/EditAuditInstance/ConnectionString.cs
index ef13fa5c34..5ef5ea0af3 100644
--- a/src/ServiceControl.Config.Tests/EditInstance/EditAuditInstance/ConnectionString.cs
+++ b/src/ServiceControl.Config.Tests/EditInstance/EditAuditInstance/ConnectionString.cs
@@ -40,38 +40,37 @@ public static ServiceControlAuditEditViewModel When_no_transport_is_selected(thi
class EditAuditConnectionStringsTests
{
- // TODO uncomment tests when MSMQ is added back
- //[Test]
- //public void MSMQ_transport_is_selected()
- //{
- // var viewModel = Given_an_audit_instance()
- // .When_MSQMQ_transport_is_selected();
+ [Test]
+ public void MSMQ_transport_is_selected()
+ {
+ var viewModel = Given_an_audit_instance()
+ .When_MSQMQ_transport_is_selected();
- // Assert.IsFalse(viewModel.ShowConnectionString);
- // Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
- // Assert.IsEmpty(viewModel.SampleConnectionString);
- // Assert.IsNull(viewModel.TransportWarning);
- //}
+ Assert.IsFalse(viewModel.ShowConnectionString);
+ Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
+ Assert.IsEmpty(viewModel.SampleConnectionString);
+ Assert.IsNull(viewModel.TransportWarning);
+ }
- //[TestAllTransportsExcept("MSMQ")]
- //public void Non_MSMQ_transport_is_selected(string transportInfoName)
- //{
- // var viewModel = Given_an_audit_instance()
- // .When_a_transport_is_selected(transportInfoName);
+ [TestAllTransportsExcept("MSMQ")]
+ public void Non_MSMQ_transport_is_selected(string transportInfoName)
+ {
+ var viewModel = Given_an_audit_instance()
+ .When_a_transport_is_selected(transportInfoName);
- // Assert.IsTrue(viewModel.ShowConnectionString);
- // StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
- // Assert.IsNotEmpty(viewModel.SampleConnectionString);
- // if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
- // {
- // Assert.IsNotNull(viewModel.TransportWarning);
- // Assert.IsNotEmpty(viewModel.TransportWarning);
- // }
- // else
- // {
- // Assert.IsNull(viewModel.TransportWarning);
- // }
- //}
+ Assert.IsTrue(viewModel.ShowConnectionString);
+ StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
+ Assert.IsNotEmpty(viewModel.SampleConnectionString);
+ if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
+ {
+ Assert.IsNotNull(viewModel.TransportWarning);
+ Assert.IsNotEmpty(viewModel.TransportWarning);
+ }
+ else
+ {
+ Assert.IsNull(viewModel.TransportWarning);
+ }
+ }
[Test]
public void Screen_Loaded()
diff --git a/src/ServiceControl.Config.Tests/EditInstance/EditErrorInstance/ConnectionString.cs b/src/ServiceControl.Config.Tests/EditInstance/EditErrorInstance/ConnectionString.cs
index c2bb531628..418487d9a2 100644
--- a/src/ServiceControl.Config.Tests/EditInstance/EditErrorInstance/ConnectionString.cs
+++ b/src/ServiceControl.Config.Tests/EditInstance/EditErrorInstance/ConnectionString.cs
@@ -41,38 +41,37 @@ public static ServiceControlEditViewModel When_no_transport_is_selected(this Ser
class EditErrorConnectionStringsTests
{
- // TODO uncomment tests when MSMQ is added back
- //[Test]
- //public void MSMQ_transport_is_selected()
- //{
- // var viewModel = Given_a_service_control_instance()
- // .When_MSQMQ_transport_is_selected();
-
- // Assert.IsFalse(viewModel.ShowConnectionString);
- // Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
- // Assert.IsEmpty(viewModel.SampleConnectionString);
- // Assert.IsNull(viewModel.TransportWarning);
- //}
-
- //[TestAllTransportsExcept("MSMQ")]
- //public void Non_MSMQ_transport_is_selected(string transportInfoName)
- //{
- // var viewModel = Given_a_service_control_instance()
- // .When_a_transport_is_selected(transportInfoName);
-
- // Assert.IsTrue(viewModel.ShowConnectionString);
- // StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
- // Assert.IsNotEmpty(viewModel.SampleConnectionString);
- // if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
- // {
- // Assert.IsNotNull(viewModel.TransportWarning);
- // Assert.IsNotEmpty(viewModel.TransportWarning);
- // }
- // else
- // {
- // Assert.IsNull(viewModel.TransportWarning);
- // }
- //}
+ [Test]
+ public void MSMQ_transport_is_selected()
+ {
+ var viewModel = Given_a_service_control_instance()
+ .When_MSQMQ_transport_is_selected();
+
+ Assert.IsFalse(viewModel.ShowConnectionString);
+ Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
+ Assert.IsEmpty(viewModel.SampleConnectionString);
+ Assert.IsNull(viewModel.TransportWarning);
+ }
+
+ [TestAllTransportsExcept("MSMQ")]
+ public void Non_MSMQ_transport_is_selected(string transportInfoName)
+ {
+ var viewModel = Given_a_service_control_instance()
+ .When_a_transport_is_selected(transportInfoName);
+
+ Assert.IsTrue(viewModel.ShowConnectionString);
+ StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
+ Assert.IsNotEmpty(viewModel.SampleConnectionString);
+ if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
+ {
+ Assert.IsNotNull(viewModel.TransportWarning);
+ Assert.IsNotEmpty(viewModel.TransportWarning);
+ }
+ else
+ {
+ Assert.IsNull(viewModel.TransportWarning);
+ }
+ }
[Test]
public void Screen_Loaded()
diff --git a/src/ServiceControl.Config.Tests/EditInstance/EditMonitoringInstance/ConnectionString.cs b/src/ServiceControl.Config.Tests/EditInstance/EditMonitoringInstance/ConnectionString.cs
index 18a25f37aa..ddfb5883fe 100644
--- a/src/ServiceControl.Config.Tests/EditInstance/EditMonitoringInstance/ConnectionString.cs
+++ b/src/ServiceControl.Config.Tests/EditInstance/EditMonitoringInstance/ConnectionString.cs
@@ -41,38 +41,37 @@ public static MonitoringEditViewModel When_no_transport_is_selected(this Monitor
class EditMonitoringConnectionStringsTests
{
- // TODO uncomment tests when MSMQ is added back
- //[Test]
- //public void MSMQ_transport_is_selected()
- //{
- // var viewModel = Given_a_monitoring_instance()
- // .When_MSQMQ_transport_is_selected();
-
- // Assert.IsFalse(viewModel.ShowConnectionString);
- // Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
- // Assert.IsEmpty(viewModel.SampleConnectionString);
- // Assert.IsNull(viewModel.TransportWarning);
- //}
-
- //[TestAllTransportsExcept("MSMQ")]
- //public void Non_MSMQ_transport_is_selected(string transportInfoName)
- //{
- // var viewModel = Given_a_monitoring_instance()
- // .When_a_transport_is_selected(transportInfoName);
-
- // Assert.IsTrue(viewModel.ShowConnectionString);
- // StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
- // Assert.IsNotEmpty(viewModel.SampleConnectionString);
- // if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
- // {
- // Assert.IsNotNull(viewModel.TransportWarning);
- // Assert.IsNotEmpty(viewModel.TransportWarning);
- // }
- // else
- // {
- // Assert.IsNull(viewModel.TransportWarning);
- // }
- //}
+ [Test]
+ public void MSMQ_transport_is_selected()
+ {
+ var viewModel = Given_a_monitoring_instance()
+ .When_MSQMQ_transport_is_selected();
+
+ Assert.IsFalse(viewModel.ShowConnectionString);
+ Assert.AreEqual("MSMQ", viewModel.SelectedTransport.Name);
+ Assert.IsEmpty(viewModel.SampleConnectionString);
+ Assert.IsNull(viewModel.TransportWarning);
+ }
+
+ [TestAllTransportsExcept("MSMQ")]
+ public void Non_MSMQ_transport_is_selected(string transportInfoName)
+ {
+ var viewModel = Given_a_monitoring_instance()
+ .When_a_transport_is_selected(transportInfoName);
+
+ Assert.IsTrue(viewModel.ShowConnectionString);
+ StringAssert.StartsWith(transportInfoName, viewModel.SelectedTransport.Name);
+ Assert.IsNotEmpty(viewModel.SampleConnectionString);
+ if (transportInfoName is "SQLServer" or "AmazonSQS" or "AzureStorageQueue")
+ {
+ Assert.IsNotNull(viewModel.TransportWarning);
+ Assert.IsNotEmpty(viewModel.TransportWarning);
+ }
+ else
+ {
+ Assert.IsNull(viewModel.TransportWarning);
+ }
+ }
[Test]
public void Screen_Loaded()
diff --git a/src/ServiceControl.Config.Tests/Validation/EditAuditInstanceValidationTests.cs b/src/ServiceControl.Config.Tests/Validation/EditAuditInstanceValidationTests.cs
index 814146f545..b6ec0c1517 100644
--- a/src/ServiceControl.Config.Tests/Validation/EditAuditInstanceValidationTests.cs
+++ b/src/ServiceControl.Config.Tests/Validation/EditAuditInstanceValidationTests.cs
@@ -48,45 +48,44 @@ public class EditAuditInstanceValidationTests
Assert.IsNotEmpty(errors);
}
- // TODO uncomment tests when MSMQ is added back
- //[TestTheseTransports("MSMQ")]
- //public void Transport_connection_string_can_be_empty_if_sample_connection_string_is_not_present_when_editing_audit_instance(
- // string transportInfoName)
- //{
- // var viewModel = new ServiceControlAuditEditViewModel
- // {
- // SelectedTransport = ServiceControlCoreTransports.Find(transportInfoName),
- // SubmitAttempted = true,
- // ConnectionString = string.Empty
- // };
+ [TestTheseTransports("MSMQ")]
+ public void Transport_connection_string_can_be_empty_if_sample_connection_string_is_not_present_when_editing_audit_instance(
+ string transportInfoName)
+ {
+ var viewModel = new ServiceControlAuditEditViewModel
+ {
+ SelectedTransport = ServiceControlCoreTransports.Find(transportInfoName),
+ SubmitAttempted = true,
+ ConnectionString = string.Empty
+ };
- // var notifyErrorInfo = GetNotifyErrorInfo(viewModel);
+ var notifyErrorInfo = GetNotifyErrorInfo(viewModel);
- // var errors = notifyErrorInfo.GetErrors(nameof(viewModel.ConnectionString));
+ var errors = notifyErrorInfo.GetErrors(nameof(viewModel.ConnectionString));
- // Assert.IsEmpty(errors);
- //}
+ Assert.IsEmpty(errors);
+ }
- //[TestTheseTransports("MSMQ")]
- //public void Transport_connection_string_can_be_null_if_sample_connection_string_is_not_present_when_editing_audit_instance(
- // string transportInfoName)
- //{
- // var viewModel = new ServiceControlAuditEditViewModel
- // {
- // SelectedTransport = ServiceControlCoreTransports.Find(transportInfoName),
- // SubmitAttempted = true,
- // ConnectionString = null
- // };
+ [TestTheseTransports("MSMQ")]
+ public void Transport_connection_string_can_be_null_if_sample_connection_string_is_not_present_when_editing_audit_instance(
+ string transportInfoName)
+ {
+ var viewModel = new ServiceControlAuditEditViewModel
+ {
+ SelectedTransport = ServiceControlCoreTransports.Find(transportInfoName),
+ SubmitAttempted = true,
+ ConnectionString = null
+ };
- // viewModel.NotifyOfPropertyChange(nameof(viewModel.ConnectionString));
+ viewModel.NotifyOfPropertyChange(nameof(viewModel.ConnectionString));
- // var notifyErrorInfo = GetNotifyErrorInfo(viewModel);
+ var notifyErrorInfo = GetNotifyErrorInfo(viewModel);
- // var errors = notifyErrorInfo.GetErrors(nameof(viewModel.ConnectionString));
+ var errors = notifyErrorInfo.GetErrors(nameof(viewModel.ConnectionString));
- // Assert.IsEmpty(errors);
+ Assert.IsEmpty(errors);
- //}
+ }
#endregion
diff --git a/src/ServiceControl.Config.Tests/Validation/EditErrorInstanceValidationTests.cs b/src/ServiceControl.Config.Tests/Validation/EditErrorInstanceValidationTests.cs
index 3ecc508672..d3ef90dec8 100644
--- a/src/ServiceControl.Config.Tests/Validation/EditErrorInstanceValidationTests.cs
+++ b/src/ServiceControl.Config.Tests/Validation/EditErrorInstanceValidationTests.cs
@@ -48,44 +48,43 @@ public class EditErrorInstanceValidationTests
Assert.IsNotEmpty(errors);
}
- // TODO uncomment tests when MSMQ is added back
- //[TestTheseTransports("MSMQ")]
- //public void Transport_connection_string_can_be_empty_if_sample_connection_string_is_not_present_when_editing_error_instance(
- // string transportInfoName)
- //{
- // var viewModel = new ServiceControlEditViewModel
- // {
- // SelectedTransport = ServiceControlCoreTransports.Find(transportInfoName),
- // SubmitAttempted = true,
- // ConnectionString = string.Empty
- // };
-
- // var notifyErrorInfo = GetNotifyErrorInfo(viewModel);
-
- // var errors = notifyErrorInfo.GetErrors(nameof(viewModel.ConnectionString));
-
- // Assert.IsEmpty(errors);
- //}
-
- //[TestTheseTransports("MSMQ")]
- //public void Transport_connection_string_can_be_null_if_sample_connection_string_is_not_present_when_editing_error_instance(
- // string transportInfoName)
- //{
- // var viewModel = new ServiceControlEditViewModel
- // {
- // SelectedTransport = ServiceControlCoreTransports.Find(transportInfoName),
- // SubmitAttempted = true,
- // ConnectionString = null
- // };
-
- // viewModel.NotifyOfPropertyChange(nameof(viewModel.ConnectionString));
-
- // var notifyErrorInfo = GetNotifyErrorInfo(viewModel);
-
- // var errors = notifyErrorInfo.GetErrors(nameof(viewModel.ConnectionString));
-
- // Assert.IsEmpty(errors);
- //}
+ [TestTheseTransports("MSMQ")]
+ public void Transport_connection_string_can_be_empty_if_sample_connection_string_is_not_present_when_editing_error_instance(
+ string transportInfoName)
+ {
+ var viewModel = new ServiceControlEditViewModel
+ {
+ SelectedTransport = ServiceControlCoreTransports.Find(transportInfoName),
+ SubmitAttempted = true,
+ ConnectionString = string.Empty
+ };
+
+ var notifyErrorInfo = GetNotifyErrorInfo(viewModel);
+
+ var errors = notifyErrorInfo.GetErrors(nameof(viewModel.ConnectionString));
+
+ Assert.IsEmpty(errors);
+ }
+
+ [TestTheseTransports("MSMQ")]
+ public void Transport_connection_string_can_be_null_if_sample_connection_string_is_not_present_when_editing_error_instance(
+ string transportInfoName)
+ {
+ var viewModel = new ServiceControlEditViewModel
+ {
+ SelectedTransport = ServiceControlCoreTransports.Find(transportInfoName),
+ SubmitAttempted = true,
+ ConnectionString = null
+ };
+
+ viewModel.NotifyOfPropertyChange(nameof(viewModel.ConnectionString));
+
+ var notifyErrorInfo = GetNotifyErrorInfo(viewModel);
+
+ var errors = notifyErrorInfo.GetErrors(nameof(viewModel.ConnectionString));
+
+ Assert.IsEmpty(errors);
+ }
#endregion
diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/AcceptanceTest.cs b/src/ServiceControl.Monitoring.AcceptanceTests/AcceptanceTest.cs
index bc0e453423..4b20fc1d21 100644
--- a/src/ServiceControl.Monitoring.AcceptanceTests/AcceptanceTest.cs
+++ b/src/ServiceControl.Monitoring.AcceptanceTests/AcceptanceTest.cs
@@ -31,12 +31,6 @@ protected AcceptanceTest()
public HttpClient HttpClient => serviceControlRunnerBehavior.HttpClient;
public JsonSerializerOptions SerializerOptions => serviceControlRunnerBehavior.SerializerOptions;
- [OneTimeSetUp]
- public static void OneTimeSetup()
- {
- Scenario.GetLoggerFactory = ctx => new StaticLoggerFactory(ctx);
- }
-
[SetUp]
public void Setup()
{
diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs b/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
index fed8cf7b28..0dd339a093 100644
--- a/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
+++ b/src/ServiceControl.Monitoring.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
@@ -1,10 +1,10 @@
namespace ServiceControl.Monitoring.AcceptanceTests.TestSupport
{
using System;
- using System.Configuration;
using System.IO;
using System.Net.Http;
using System.Text.Json;
+ using System.Threading;
using System.Threading.Tasks;
using AcceptanceTesting;
using Infrastructure;
@@ -19,7 +19,6 @@ namespace ServiceControl.Monitoring.AcceptanceTests.TestSupport
using NServiceBus.AcceptanceTesting.Support;
using NServiceBus.Configuration.AdvancedExtensibility;
using NServiceBus.Logging;
- using TestHelper;
class ServiceControlComponentRunner : ComponentRunner, IAcceptanceTestInfrastructureProvider
{
@@ -148,11 +147,11 @@ async Task InitializeServiceControl(ScenarioContext context)
}
}
- public override async Task Stop()
+ public override async Task Stop(CancellationToken cancellationToken = default)
{
using (new DiagnosticTimer($"Test TearDown for {instanceName}"))
{
- await host.StopAsync();
+ await host.StopAsync(cancellationToken);
HttpClient.Dispose();
await host.DisposeAsync();
}
diff --git a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_disconnected_count.cs b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_disconnected_count.cs
index 75c4747997..835fec4d94 100644
--- a/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_disconnected_count.cs
+++ b/src/ServiceControl.Monitoring.AcceptanceTests/When_querying_disconnected_count.cs
@@ -1,7 +1,6 @@
namespace ServiceControl.Monitoring.AcceptanceTests.Tests
{
using System;
- using System.Configuration;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.AcceptanceTesting;
@@ -25,17 +24,17 @@ public async Task Should_report_via_http()
await Define(ctx => context = ctx)
.WithEndpoint(b =>
b.CustomConfig(endpointConfig => endpointConfig.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_ENDPOINT_NAME, TimeSpan.FromMilliseconds(200), "First"))
- .ToCreateInstance(endpointConfig => Endpoint.Create(endpointConfig), async startableEndpoint =>
+ .ToCreateInstance(endpointConfig => Endpoint.Create(endpointConfig), async (startableEndpoint, cancellationToken) =>
{
- context.FirstInstance = await startableEndpoint.Start();
+ context.FirstInstance = await startableEndpoint.Start(cancellationToken);
return context.FirstInstance;
}))
.WithEndpoint(b =>
b.CustomConfig(endpointConfig => endpointConfig.EnableMetrics().SendMetricDataToServiceControl(Settings.DEFAULT_ENDPOINT_NAME, TimeSpan.FromMilliseconds(200), "Second"))
- .ToCreateInstance(endpointConfig => Endpoint.Create(endpointConfig), async startableEndpoint =>
+ .ToCreateInstance(endpointConfig => Endpoint.Create(endpointConfig), async (startableEndpoint, cancellationToken) =>
{
- context.SecondInstance = await startableEndpoint.Start();
+ context.SecondInstance = await startableEndpoint.Start(cancellationToken);
return context.SecondInstance;
}))
diff --git a/src/ServiceControl.Monitoring/Hosting/Commands/RunCommand.cs b/src/ServiceControl.Monitoring/Hosting/Commands/RunCommand.cs
index 99917a242f..ec4c96684e 100644
--- a/src/ServiceControl.Monitoring/Hosting/Commands/RunCommand.cs
+++ b/src/ServiceControl.Monitoring/Hosting/Commands/RunCommand.cs
@@ -13,8 +13,8 @@ public override async Task Execute(Settings settings)
var hostBuilder = WebApplication.CreateBuilder();
hostBuilder.AddServiceControlMonitoring((_, __) => Task.CompletedTask, settings, endpointConfiguration);
- using var app = hostBuilder.Build();
+ var app = hostBuilder.Build();
app.UseServiceControlMonitoring();
await app.RunAsync();
}
diff --git a/src/ServiceControl.Monitoring/WebApplicationBuilderExtensions.cs b/src/ServiceControl.Monitoring/WebApplicationBuilderExtensions.cs
index df006f508a..cd8527da81 100644
--- a/src/ServiceControl.Monitoring/WebApplicationBuilderExtensions.cs
+++ b/src/ServiceControl.Monitoring/WebApplicationBuilderExtensions.cs
@@ -65,14 +65,10 @@ public static class WebApplicationBuilderExtensions
// is only available though after the NServiceBus hosted service has started. Any hosted service
// or component injected into a hosted service can only depend on this lazy instead of the dispatcher
// directly and to make things more complex of course the order of registration still matters ;)
- services.AddSingleton(provider =>
- new Lazy(provider.GetRequiredService));
+ services.AddSingleton(provider => new Lazy(provider.GetRequiredService));
- hostBuilder.Host.UseNServiceBus(builder =>
- {
- ConfigureEndpoint(endpointConfiguration, onCriticalError, transportCustomization, settings);
- return endpointConfiguration;
- });
+ ConfigureEndpoint(endpointConfiguration, onCriticalError, transportCustomization, settings);
+ hostBuilder.UseNServiceBus(endpointConfiguration);
// TODO Verify if that we need to check the expose API flag
// We also don't do this in the primary instance
@@ -115,7 +111,13 @@ internal static void ConfigureEndpoint(EndpointConfiguration config, Func();
config.UsePersistence();
+
+ var recoverability = config.Recoverability();
+ recoverability.Immediate(c => c.NumberOfRetries(3));
+ recoverability.Delayed(c => c.NumberOfRetries(0));
+
config.SendFailedMessagesTo(settings.ErrorQueue);
+
config.DisableFeature();
config.AddDeserializer();
diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs
index 9c503877d5..e7b89cf80f 100644
--- a/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs
+++ b/src/ServiceControl.MultiInstance.AcceptanceTests/AcceptanceTest.cs
@@ -36,9 +36,6 @@ protected AcceptanceTest()
public Dictionary SerializerOptions => serviceControlRunnerBehavior.SerializerOptions;
public Dictionary SettingsPerInstance => serviceControlRunnerBehavior.SettingsPerInstance;
- [OneTimeSetUp]
- public static void OneTimeSetup() => Scenario.GetLoggerFactory = ctx => new StaticLoggerFactory(ctx);
-
[SetUp]
public void Setup()
{
diff --git a/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs b/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
index 5ea284699d..e8e4f833d3 100644
--- a/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
+++ b/src/ServiceControl.MultiInstance.AcceptanceTests/TestSupport/ServiceControlComponentRunner.cs
@@ -6,6 +6,7 @@ namespace ServiceControl.MultiInstance.AcceptanceTests.TestSupport
using System.Net.Http;
using System.Reflection;
using System.Text.Json;
+ using System.Threading;
using System.Threading.Tasks;
using AcceptanceTesting;
using Audit.AcceptanceTests;
@@ -16,11 +17,11 @@ namespace ServiceControl.MultiInstance.AcceptanceTests.TestSupport
using NServiceBus.AcceptanceTesting;
using NServiceBus.AcceptanceTesting.Support;
using ServiceBus.Management.Infrastructure.Settings;
- using EndpointConfiguration = NServiceBus.EndpointConfiguration;
+ using AuditInstanceSettings = ServiceControl.Audit.Infrastructure.Settings.Settings;
using AuditInstanceTestsSupport = ServiceControl.Audit.AcceptanceTests.TestSupport;
- using PrimaryInstanceTestsSupport = ServiceControl.AcceptanceTests.TestSupport;
+ using EndpointConfiguration = NServiceBus.EndpointConfiguration;
using PrimaryInstanceSettings = ServiceBus.Management.Infrastructure.Settings.Settings;
- using AuditInstanceSettings = ServiceControl.Audit.Infrastructure.Settings.Settings;
+ using PrimaryInstanceTestsSupport = ServiceControl.AcceptanceTests.TestSupport;
class ServiceControlComponentRunner : ComponentRunner, IAcceptanceTestInfrastructureProviderMultiInstance
{
@@ -140,10 +141,10 @@ public async Task Initialize(RunDescriptor run)
SerializerOptions[PrimaryInstanceSettings.DEFAULT_SERVICE_NAME] = primaryInstanceComponentRunner.SerializerOptions;
}
- public override async Task Stop()
+ public override async Task Stop(CancellationToken cancellationToken = default)
{
- await auditInstanceComponentRunner.Stop();
- await primaryInstanceComponentRunner.Stop();
+ await auditInstanceComponentRunner.Stop(cancellationToken);
+ await primaryInstanceComponentRunner.Stop(cancellationToken);
}
ITransportIntegration transportToUse;
diff --git a/src/ServiceControl.Transports.Msmq.Tests/ServiceControl.Transports.Msmq.Tests.csproj b/src/ServiceControl.Transports.Msmq.Tests/ServiceControl.Transports.Msmq.Tests.csproj
index aa6f0c65b4..3d15a7b18a 100644
--- a/src/ServiceControl.Transports.Msmq.Tests/ServiceControl.Transports.Msmq.Tests.csproj
+++ b/src/ServiceControl.Transports.Msmq.Tests/ServiceControl.Transports.Msmq.Tests.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net8.0-windows
@@ -23,13 +23,13 @@
+
+
-
-
\ No newline at end of file
diff --git a/src/ServiceControl.Transports.Msmq/QueueLengthProvider.cs b/src/ServiceControl.Transports.Msmq/QueueLengthProvider.cs
index 00539c3326..b87130bd96 100644
--- a/src/ServiceControl.Transports.Msmq/QueueLengthProvider.cs
+++ b/src/ServiceControl.Transports.Msmq/QueueLengthProvider.cs
@@ -11,7 +11,7 @@ public void Initialize(string connectionString, Action Task.CompletedTask;
diff --git a/src/ServiceControl.Transports.Msmq/ServiceControl.Transports.Msmq.csproj b/src/ServiceControl.Transports.Msmq/ServiceControl.Transports.Msmq.csproj
index 140ee47bfe..20e0fabd38 100644
--- a/src/ServiceControl.Transports.Msmq/ServiceControl.Transports.Msmq.csproj
+++ b/src/ServiceControl.Transports.Msmq/ServiceControl.Transports.Msmq.csproj
@@ -1,7 +1,8 @@
- net8.0
+ net8.0-windows
+ true
@@ -10,8 +11,10 @@
-
+
+
+
@@ -19,7 +22,7 @@
-
+
diff --git a/src/ServiceControl.Transports.Msmq/transport.manifest b/src/ServiceControl.Transports.Msmq/transport.manifest
index 76e4a63cf7..d0e85b5904 100644
--- a/src/ServiceControl.Transports.Msmq/transport.manifest
+++ b/src/ServiceControl.Transports.Msmq/transport.manifest
@@ -7,7 +7,6 @@
"TypeName": "ServiceControl.Transports.Msmq.MsmqTransportCustomization, ServiceControl.Transports.Msmq",
"SampleConnectionString": "",
"AvailableInSCMU": true,
- "Default": true,
"Aliases": [
"NServiceBus.MsmqTransport, NServiceBus.Transport.Msmq",
"NServiceBus.MsmqTransport, NServiceBus.Core"
diff --git a/src/ServiceControl.Transports.RabbitMQ/ConnectionFactory.cs b/src/ServiceControl.Transports.RabbitMQ/ConnectionFactory.cs
index 0ea69071fb..f0fe35fc6e 100644
--- a/src/ServiceControl.Transports.RabbitMQ/ConnectionFactory.cs
+++ b/src/ServiceControl.Transports.RabbitMQ/ConnectionFactory.cs
@@ -45,7 +45,6 @@ public ConnectionFactory(string endpointName, ConnectionConfiguration connection
Password = connectionConfiguration.Password,
RequestedHeartbeat = heartbeatInterval ?? connectionConfiguration.RequestedHeartbeat,
NetworkRecoveryInterval = networkRecoveryInterval ?? connectionConfiguration.RetryDelay,
- UseBackgroundThreadsForIO = true
};
connectionFactory.Ssl.ServerName = connectionConfiguration.Host;
diff --git a/src/ServiceControl.Transports.RabbitMQClassicConventionalRouting.Tests/ServiceControl.Transports.RabbitMQClassicConventionalRoutingTests.csproj b/src/ServiceControl.Transports.RabbitMQClassicConventionalRouting.Tests/ServiceControl.Transports.RabbitMQClassicConventionalRoutingTests.csproj
index a5d75ecda1..4c93060f75 100644
--- a/src/ServiceControl.Transports.RabbitMQClassicConventionalRouting.Tests/ServiceControl.Transports.RabbitMQClassicConventionalRoutingTests.csproj
+++ b/src/ServiceControl.Transports.RabbitMQClassicConventionalRouting.Tests/ServiceControl.Transports.RabbitMQClassicConventionalRoutingTests.csproj
@@ -15,8 +15,8 @@
-
-
+
+
diff --git a/src/ServiceControl.Transports.Tests/API/APIApprovals.cs b/src/ServiceControl.Transports.Tests/API/APIApprovals.cs
index b83f4a6eba..520ae76c10 100644
--- a/src/ServiceControl.Transports.Tests/API/APIApprovals.cs
+++ b/src/ServiceControl.Transports.Tests/API/APIApprovals.cs
@@ -13,7 +13,7 @@ public void ServiceControlTransport()
{
var serviceControlTransportApi = typeof(TransportSettings).Assembly.GeneratePublicApi(new ApiGeneratorOptions
{
- ExcludeAttributes = new[] { "System.Reflection.AssemblyMetadataAttribute" }
+ ExcludeAttributes = ["System.Reflection.AssemblyMetadataAttribute"]
});
Approver.Verify(serviceControlTransportApi);
diff --git a/src/ServiceControl.Transports.Tests/ApprovalFiles/TransportManifestLibraryTests.All_types_defined_in_manifest_files_exist_in_specified_assembly.approved.txt b/src/ServiceControl.Transports.Tests/ApprovalFiles/TransportManifestLibraryTests.All_types_defined_in_manifest_files_exist_in_specified_assembly.approved.txt
index 7f6350c40b..6318beb0ad 100644
--- a/src/ServiceControl.Transports.Tests/ApprovalFiles/TransportManifestLibraryTests.All_types_defined_in_manifest_files_exist_in_specified_assembly.approved.txt
+++ b/src/ServiceControl.Transports.Tests/ApprovalFiles/TransportManifestLibraryTests.All_types_defined_in_manifest_files_exist_in_specified_assembly.approved.txt
@@ -3,6 +3,7 @@
"AzureStorageQueue",
"LearningTransport",
"LearningTransport",
+ "MSMQ",
"NetStandardAzureServiceBus",
"RabbitMQ.ClassicConventionalRouting",
"RabbitMQ.ClassicDirectRouting",
diff --git a/src/ServiceControl.Transports.Tests/BasicEndpointSetup.cs b/src/ServiceControl.Transports.Tests/BasicEndpointSetup.cs
index 352a49a21b..3d86933d1b 100644
--- a/src/ServiceControl.Transports.Tests/BasicEndpointSetup.cs
+++ b/src/ServiceControl.Transports.Tests/BasicEndpointSetup.cs
@@ -19,6 +19,10 @@ public class BasicEndpointSetup : IEndpointSetupTemplate
endpointConfiguration.UseSerialization();
endpointConfiguration.RegisterComponentsAndInheritanceHierarchy(runDescriptor);
+ var recoverability = endpointConfiguration.Recoverability();
+ recoverability.Immediate(c => c.NumberOfRetries(3));
+ recoverability.Delayed(c => c.NumberOfRetries(0));
+
await configurationBuilderCustomization(endpointConfiguration);
// scan types at the end so that all types used by the configuration have been loaded into the AppDomain
diff --git a/src/ServiceControl.Transports.Tests/QueueProvisioningTests.cs b/src/ServiceControl.Transports.Tests/QueueProvisioningTests.cs
index a77fa32b01..98e5942431 100644
--- a/src/ServiceControl.Transports.Tests/QueueProvisioningTests.cs
+++ b/src/ServiceControl.Transports.Tests/QueueProvisioningTests.cs
@@ -1,6 +1,5 @@
namespace ServiceControl.Transport.Tests
{
- using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
diff --git a/src/ServiceControl.Transports.Tests/ServiceControlEndpointTests.cs b/src/ServiceControl.Transports.Tests/ServiceControlEndpointTests.cs
index c468b996aa..40e9969f04 100644
--- a/src/ServiceControl.Transports.Tests/ServiceControlEndpointTests.cs
+++ b/src/ServiceControl.Transports.Tests/ServiceControlEndpointTests.cs
@@ -1,6 +1,5 @@
namespace ServiceControl.Transport.Tests
{
- using System.Collections.Generic;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.AcceptanceTesting;
diff --git a/src/ServiceControl.Transports.Tests/ServiceControlMonitoringEndpointTests.cs b/src/ServiceControl.Transports.Tests/ServiceControlMonitoringEndpointTests.cs
index e6e06123b3..91fd7ddd7d 100644
--- a/src/ServiceControl.Transports.Tests/ServiceControlMonitoringEndpointTests.cs
+++ b/src/ServiceControl.Transports.Tests/ServiceControlMonitoringEndpointTests.cs
@@ -1,6 +1,5 @@
namespace ServiceControl.Transport.Tests
{
- using System.Collections.Generic;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.AcceptanceTesting;
diff --git a/src/ServiceControl.Transports.Tests/StaticContextAppender.cs b/src/ServiceControl.Transports.Tests/StaticContextAppender.cs
deleted file mode 100644
index f8d34b431e..0000000000
--- a/src/ServiceControl.Transports.Tests/StaticContextAppender.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-namespace ServiceControl.Transport.Tests
-{
- using System;
- using System.Diagnostics;
- using System.Reflection;
- using NServiceBus.AcceptanceTesting;
- using NServiceBus.Logging;
-
- class StaticContextAppender : ILog
- {
- public bool IsDebugEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Debug;
- public bool IsInfoEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Info;
- public bool IsWarnEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Warn;
- public bool IsErrorEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Error;
- public bool IsFatalEnabled => StaticLoggerFactory.CurrentContext.LogLevel <= LogLevel.Fatal;
-
-
- public void Debug(string message)
- {
- Log(message, LogLevel.Debug);
- }
-
- public void Debug(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Debug);
- }
-
- public void DebugFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Debug);
- }
-
- public void Info(string message)
- {
- Log(message, LogLevel.Info);
- }
-
- public void Info(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Info);
- }
-
- public void InfoFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Info);
- }
-
- public void Warn(string message)
- {
- Log(message, LogLevel.Warn);
- }
-
- public void Warn(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Warn);
- }
-
- public void WarnFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Warn);
- }
-
- public void Error(string message)
- {
- Log(message, LogLevel.Error);
- }
-
- public void Error(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Error);
- }
-
- public void ErrorFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Error);
- }
-
- public void Fatal(string message)
- {
- Log(message, LogLevel.Fatal);
- }
-
- public void Fatal(string message, Exception exception)
- {
- var fullMessage = $"{message} {exception}";
- Log(fullMessage, LogLevel.Fatal);
- }
-
- public void FatalFormat(string format, params object[] args)
- {
- var fullMessage = string.Format(format, args);
- Log(fullMessage, LogLevel.Fatal);
- }
-
- void Log(string message, LogLevel messageSeverity)
- {
- if (StaticLoggerFactory.CurrentContext.LogLevel > messageSeverity)
- {
- return;
- }
-
- Trace.WriteLine(message);
- StaticLoggerFactory.CurrentContext.Logs.Enqueue(new ScenarioContext.LogItem
- {
- Endpoint = (string)typeof(ScenarioContext).GetProperty("CurrentEndpoint", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(StaticLoggerFactory.CurrentContext),
- Level = messageSeverity,
- Message = message
- });
- }
- }
-}
\ No newline at end of file
diff --git a/src/ServiceControl.Transports.Tests/StaticLoggerFactory.cs b/src/ServiceControl.Transports.Tests/StaticLoggerFactory.cs
deleted file mode 100644
index bd530d4df6..0000000000
--- a/src/ServiceControl.Transports.Tests/StaticLoggerFactory.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-namespace ServiceControl.Transport.Tests
-{
- using System;
- using NServiceBus.AcceptanceTesting;
- using NServiceBus.Logging;
-
- public class StaticLoggerFactory : ILoggerFactory
- {
- public StaticLoggerFactory(ScenarioContext currentContext)
- {
- CurrentContext = currentContext;
- }
-
- public ILog GetLogger(Type type)
- {
- return GetLogger(type.FullName);
- }
-
- public ILog GetLogger(string name)
- {
- return new StaticContextAppender();
- }
-
- public static ScenarioContext CurrentContext;
- }
-}
\ No newline at end of file
diff --git a/src/ServiceControl.Transports.Tests/TestDispatcherExtensions.cs b/src/ServiceControl.Transports.Tests/TestDispatcherExtensions.cs
index 252dbfdad1..785b87551b 100644
--- a/src/ServiceControl.Transports.Tests/TestDispatcherExtensions.cs
+++ b/src/ServiceControl.Transports.Tests/TestDispatcherExtensions.cs
@@ -1,7 +1,6 @@
namespace ServiceControl.Transport.Tests
{
using System;
- using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/ServiceControl.Transports.Tests/TransportTestFixture.cs b/src/ServiceControl.Transports.Tests/TransportTestFixture.cs
index 0fa049e678..e73b5249dc 100644
--- a/src/ServiceControl.Transports.Tests/TransportTestFixture.cs
+++ b/src/ServiceControl.Transports.Tests/TransportTestFixture.cs
@@ -6,7 +6,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
- using NServiceBus.AcceptanceTesting;
using NServiceBus.AcceptanceTesting.Customization;
using NServiceBus.Transport;
using NUnit.Framework;
@@ -16,9 +15,6 @@
[TestFixture]
class TransportTestFixture
{
- [OneTimeSetUp]
- public static void OneTimeSetup() => Scenario.GetLoggerFactory = ctx => new StaticLoggerFactory(ctx);
-
[SetUp]
public virtual async Task Setup()
{
diff --git a/src/ServiceControl.Transports/DevelopmentTransportLocations.cs b/src/ServiceControl.Transports/DevelopmentTransportLocations.cs
index 5998b29ef1..cf6d111c10 100644
--- a/src/ServiceControl.Transports/DevelopmentTransportLocations.cs
+++ b/src/ServiceControl.Transports/DevelopmentTransportLocations.cs
@@ -20,14 +20,14 @@ static DevelopmentTransportLocations()
ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Transports.ASBS"));
ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Transports.ASQ"));
ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Transports.Learning"));
- //ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Transports.Msmq")); TODO Uncomment when we add MSMQ back in
+ ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Transports.Msmq", "net8.0-windows"));
ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Transports.RabbitMQ"));
ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Transports.SqlServer"));
ManifestFiles.Add(BuildManifestPath(srcFolder, "ServiceControl.Transports.SQS"));
}
}
- static string BuildManifestPath(string srcFolder, string projectName) => Path.Combine(srcFolder, projectName, "bin", configuration, framework, "transport.manifest");
+ static string BuildManifestPath(string srcFolder, string projectName, string frameworkOverride = null) => Path.Combine(srcFolder, projectName, "bin", configuration, frameworkOverride ?? framework, "transport.manifest");
#if DEBUG
const string configuration = "Debug";
diff --git a/src/ServiceControl.UnitTests/ServiceControl.UnitTests.csproj b/src/ServiceControl.UnitTests/ServiceControl.UnitTests.csproj
index 2bb88c9410..1198985558 100644
--- a/src/ServiceControl.UnitTests/ServiceControl.UnitTests.csproj
+++ b/src/ServiceControl.UnitTests/ServiceControl.UnitTests.csproj
@@ -7,7 +7,6 @@
-
diff --git a/src/ServiceControl.sln b/src/ServiceControl.sln
index 59c50ff5b8..c9e917651b 100644
--- a/src/ServiceControl.sln
+++ b/src/ServiceControl.sln
@@ -153,6 +153,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LegacyArtifacts", "LegacyAr
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Testing", "Testing", "{E067C14F-867B-4479-BC85-39F2AFAF25D0}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceControl.Transports.Msmq", "ServiceControl.Transports.Msmq\ServiceControl.Transports.Msmq.csproj", "{F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceControl.Transports.Msmq.Tests", "ServiceControl.Transports.Msmq.Tests\ServiceControl.Transports.Msmq.Tests.csproj", "{5F8E6C64-B505-4FF7-81CC-9161FBC198A8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -821,6 +825,30 @@ Global
{38147B68-13EE-48DC-BB38-4217889978AE}.Release|x64.Build.0 = Release|Any CPU
{38147B68-13EE-48DC-BB38-4217889978AE}.Release|x86.ActiveCfg = Release|Any CPU
{38147B68-13EE-48DC-BB38-4217889978AE}.Release|x86.Build.0 = Release|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Debug|x64.Build.0 = Debug|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Debug|x86.Build.0 = Debug|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Release|x64.ActiveCfg = Release|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Release|x64.Build.0 = Release|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Release|x86.ActiveCfg = Release|Any CPU
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE}.Release|x86.Build.0 = Release|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Debug|x64.Build.0 = Debug|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Debug|x86.Build.0 = Debug|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Release|x64.ActiveCfg = Release|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Release|x64.Build.0 = Release|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Release|x86.ActiveCfg = Release|Any CPU
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -890,6 +918,8 @@ Global
{4F2CAFC7-113A-4D31-A365-6669AB4C7787} = {350F72AB-142D-4AAD-9EF1-1A83DC991D87}
{38147B68-13EE-48DC-BB38-4217889978AE} = {55C388DD-2B39-4C2F-AEBD-AFD3444815F1}
{E067C14F-867B-4479-BC85-39F2AFAF25D0} = {E2249BAA-D9E9-4369-9C70-0E21C69A3E56}
+ {F04B9D2C-7E31-4697-BAE3-D3FFC5FBBDFE} = {A21A1A89-0B07-4E87-8E3C-41D9C280DCB8}
+ {5F8E6C64-B505-4FF7-81CC-9161FBC198A8} = {E0E45F22-35E3-4AD8-B09E-EFEA5A2F18EE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3B9E5B72-F580-465A-A22C-2D2148AF4EB4}
diff --git a/src/ServiceControl/Hosting/Commands/ImportFailedErrorsCommand.cs b/src/ServiceControl/Hosting/Commands/ImportFailedErrorsCommand.cs
index 58445999f8..444a5c983b 100644
--- a/src/ServiceControl/Hosting/Commands/ImportFailedErrorsCommand.cs
+++ b/src/ServiceControl/Hosting/Commands/ImportFailedErrorsCommand.cs
@@ -28,10 +28,10 @@ public override async Task Execute(HostArguments args, Settings settings)
// TODO: Ideally we would never want to actually bootstrap the web api. Figure out how
var hostBuilder = WebApplication.CreateBuilder();
hostBuilder.AddServiceControl(settings, endpointConfiguration, loggingSettings);
- using var app = hostBuilder.Build();
+ using var app = hostBuilder.Build();
app.UseServiceControl();
- await app.StartServiceControl();
+ await app.StartAsync();
var importFailedErrors = app.Services.GetRequiredService();
diff --git a/src/ServiceControl/Hosting/Commands/RunCommand.cs b/src/ServiceControl/Hosting/Commands/RunCommand.cs
index 31c5f01820..ffb6f08648 100644
--- a/src/ServiceControl/Hosting/Commands/RunCommand.cs
+++ b/src/ServiceControl/Hosting/Commands/RunCommand.cs
@@ -4,7 +4,6 @@
using global::ServiceControl;
using Hosting;
using Microsoft.AspNetCore.Builder;
- using Microsoft.Extensions.Hosting;
using NServiceBus;
using ServiceBus.Management.Infrastructure.Settings;
@@ -22,11 +21,10 @@ public override async Task Execute(HostArguments args, Settings settings)
var hostBuilder = WebApplication.CreateBuilder();
hostBuilder.AddServiceControl(settings, endpointConfiguration, loggingSettings);
- using var app = hostBuilder.Build();
+ var app = hostBuilder.Build();
app.UseServiceControl();
- await app.StartServiceControl();
- await app.WaitForShutdownAsync();
+ await app.RunAsync();
}
}
}
diff --git a/src/ServiceControl/Infrastructure/NServiceBusFactory.cs b/src/ServiceControl/Infrastructure/NServiceBusFactory.cs
index baf6d350a1..2203b27f4e 100644
--- a/src/ServiceControl/Infrastructure/NServiceBusFactory.cs
+++ b/src/ServiceControl/Infrastructure/NServiceBusFactory.cs
@@ -39,6 +39,7 @@ static class NServiceBusFactory
recoverability.Immediate(c => c.NumberOfRetries(3));
recoverability.Delayed(c => c.NumberOfRetries(0));
recoverability.AddUnrecoverableException();
+
configuration.SendFailedMessagesTo(transportSettings.ErrorQueue);
recoverability.CustomPolicy(SendEmailNotificationHandler.RecoverabilityPolicy);
diff --git a/src/ServiceControl/Infrastructure/Subscriptions/SubscriptionStorage.cs b/src/ServiceControl/Infrastructure/Subscriptions/SubscriptionStorage.cs
index 9095bb4357..dbce55d1e3 100644
--- a/src/ServiceControl/Infrastructure/Subscriptions/SubscriptionStorage.cs
+++ b/src/ServiceControl/Infrastructure/Subscriptions/SubscriptionStorage.cs
@@ -17,7 +17,7 @@ class SubscriptionStorage : Feature
protected override void Setup(FeatureConfigurationContext context)
{
- context.RegisterStartupTask(b => b.GetRequiredService());
+ context.RegisterStartupTask(b => new PrimeSubscriptions(b.GetRequiredService()));
}
class PrimeSubscriptions : FeatureStartupTask
diff --git a/src/ServiceControl/WebApplicationBuilderExtension.cs b/src/ServiceControl/WebApplicationBuilderExtension.cs
index d35987e4bb..c02e3b7756 100644
--- a/src/ServiceControl/WebApplicationBuilderExtension.cs
+++ b/src/ServiceControl/WebApplicationBuilderExtension.cs
@@ -92,11 +92,9 @@ public static void AddServiceControl(this WebApplicationBuilder hostBuilder, Set
hostBuilder.AddLicenseCheck();
services.AddPersistence(settings);
services.AddMetrics(settings.PrintMetrics);
- hostBuilder.Host.UseNServiceBus(_ =>
- {
- NServiceBusFactory.Configure(settings, transportCustomization, transportSettings, loggingSettings, configuration);
- return configuration;
- });
+
+ NServiceBusFactory.Configure(settings, transportCustomization, transportSettings, loggingSettings, configuration);
+ hostBuilder.UseNServiceBus(configuration);
if (!settings.DisableExternalIntegrationsPublishing)
{
diff --git a/src/ServiceControl/WebApplicationExtensions.cs b/src/ServiceControl/WebApplicationExtensions.cs
index ee6898c6a5..51f202f6fd 100644
--- a/src/ServiceControl/WebApplicationExtensions.cs
+++ b/src/ServiceControl/WebApplicationExtensions.cs
@@ -1,6 +1,5 @@
namespace ServiceControl;
-using System.Threading.Tasks;
using Infrastructure.OWIN;
using Infrastructure.SignalR;
using Microsoft.AspNetCore.Builder;
@@ -16,9 +15,4 @@ public static void UseServiceControl(this WebApplication app)
app.UseCors();
app.MapControllers();
}
-
- public static async Task StartServiceControl(this WebApplication app)
- {
- await app.StartAsync();
- }
}
\ No newline at end of file
diff --git a/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/APIApprovals.TransportNames.approved.txt b/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/APIApprovals.TransportNames.approved.txt
index abc7b565d3..d172846297 100644
--- a/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/APIApprovals.TransportNames.approved.txt
+++ b/src/ServiceControlInstaller.Engine.UnitTests/ApprovalFiles/APIApprovals.TransportNames.approved.txt
@@ -40,6 +40,14 @@
"DisplayName": "Learning Transport (Non-Production)",
"Aliases": []
},
+ {
+ "Name": "MSMQ",
+ "DisplayName": "MSMQ",
+ "Aliases": [
+ "NServiceBus.MsmqTransport, NServiceBus.Transport.Msmq",
+ "NServiceBus.MsmqTransport, NServiceBus.Core"
+ ]
+ },
{
"Name": "NetStandardAzureServiceBus",
"DisplayName": "Azure Service Bus",
diff --git a/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs b/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs
index 6c1d248000..94e6a57eb8 100644
--- a/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs
+++ b/src/ServiceControlInstaller.Engine/Instances/MonitoringInstance.cs
@@ -96,14 +96,12 @@ string ReadConnectionString()
TransportInfo DetermineTransportPackage()
{
- var transportAppSetting = AppConfig.Read(SettingsList.TransportType, null)?.Trim();
+ var transportAppSetting = (AppConfig.Read(SettingsList.TransportType, null)?.Trim())
+ ?? throw new Exception($"{SettingsList.TransportType.Name} setting not found in app.config.");
+
var transport = ServiceControlCoreTransports.Find(transportAppSetting);
- if (transport != null)
- {
- return transport;
- }
- return ServiceControlCoreTransports.GetDefaultTransport();
+ return transport ?? throw new Exception($"{SettingsList.TransportType.Name} value of '{transportAppSetting}' in app.config is invalid.");
}
public async Task ValidateChanges()
diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs
index 222f6a6a30..1e18a3d7b7 100644
--- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs
+++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlAuditInstance.cs
@@ -53,9 +53,14 @@ protected override AppConfig CreateAppConfig()
return new ServiceControlAuditAppConfig(this);
}
- protected override string GetTransportTypeSetting()
+ protected override TransportInfo DetermineTransportPackage()
{
- return AppConfig.Read(AuditInstanceSettingsList.TransportType, null)?.Trim();
+ var transportAppSetting = (AppConfig.Read(AuditInstanceSettingsList.TransportType, null)?.Trim())
+ ?? throw new Exception($"{AuditInstanceSettingsList.TransportType.Name} setting not found in app.config.");
+
+ var transport = ServiceControlCoreTransports.Find(transportAppSetting);
+
+ return transport ?? throw new Exception($"{AuditInstanceSettingsList.TransportType.Name} value of '{transportAppSetting}' in app.config is invalid.");
}
protected override string BaseServiceName => "ServiceControl.Audit";
diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs
index b003e10e7e..cd35c4349b 100644
--- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs
+++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlBaseService.cs
@@ -10,7 +10,6 @@ namespace ServiceControlInstaller.Engine.Instances
using System.Threading.Tasks;
using Accounts;
using Configuration;
- using Configuration.ServiceControl;
using FileSystem;
using NuGet.Versioning;
using Queues;
@@ -19,6 +18,8 @@ namespace ServiceControlInstaller.Engine.Instances
using UrlAcl;
using Validation;
+ using AppConfig = Configuration.ServiceControl.AppConfig;
+
public abstract class ServiceControlBaseService : BaseService
{
protected ServiceControlBaseService(IWindowsServiceController service)
@@ -140,19 +141,7 @@ protected string ReadConnectionString()
return null;
}
- protected abstract string GetTransportTypeSetting();
-
- protected TransportInfo DetermineTransportPackage()
- {
- var transportAppSetting = GetTransportTypeSetting();
- var transport = ServiceControlCoreTransports.Find(transportAppSetting);
- if (transport != null)
- {
- return transport;
- }
-
- return ServiceControlCoreTransports.GetDefaultTransport();
- }
+ protected abstract TransportInfo DetermineTransportPackage();
protected void RecreateUrlAcl(ServiceControlBaseService oldSettings)
{
diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlCoreTransports.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlCoreTransports.cs
index 52baa68d55..d528c6a3a2 100644
--- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlCoreTransports.cs
+++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlCoreTransports.cs
@@ -10,12 +10,9 @@ public static class ServiceControlCoreTransports
{
static readonly TransportInfo[] all;
static readonly TransportInfo[] supported;
- static readonly TransportInfo defaultTransport;
public static TransportInfo[] GetSupportedTransports() => supported;
- public static TransportInfo GetDefaultTransport() => defaultTransport;
-
// Only tests should use this
internal static TransportInfo[] GetAllTransports() => all;
@@ -36,9 +33,6 @@ static ServiceControlCoreTransports()
all.First(t => t.Name == "LearningTransport").AvailableInSCMU = IncludeLearningTransport();
supported = all.Where(t => t.AvailableInSCMU).ToArray();
-
- // TODO Changed this to SingleOrDefault and made LearningTransport default for now since MSMQ is default currently. Seems like we'll need to choose a new default also?
- defaultTransport = all.SingleOrDefault(t => t.Default) ?? all.First(t => t.Name == "LearningTransport");
}
static TransportInfo[] Load(Assembly assembly, string resourceName)
diff --git a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs
index 6ca34b1891..6d1b40717b 100644
--- a/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs
+++ b/src/ServiceControlInstaller.Engine/Instances/ServiceControlInstance.cs
@@ -13,6 +13,8 @@ namespace ServiceControlInstaller.Engine.Instances
using Services;
using Validation;
+ using AppConfig = Configuration.ServiceControl.AppConfig;
+
public class ServiceControlInstance : ServiceControlBaseService, IServiceControlInstance
{
public ServiceControlInstance(IWindowsServiceController service) : base(service)
@@ -39,9 +41,14 @@ public void AddRemoteInstance(string apiUri)
}
}
- protected override string GetTransportTypeSetting()
+ protected override TransportInfo DetermineTransportPackage()
{
- return AppConfig.Read(ServiceControlSettings.TransportType, null)?.Trim();
+ var transportAppSetting = (AppConfig.Read(ServiceControlSettings.TransportType, null)?.Trim())
+ ?? throw new Exception($"{ServiceControlSettings.TransportType.Name} setting not found in app.config.");
+
+ var transport = ServiceControlCoreTransports.Find(transportAppSetting);
+
+ return transport ?? throw new Exception($"{ServiceControlSettings.TransportType.Name} value of '{transportAppSetting}' in app.config is invalid.");
}
protected override AppConfig CreateAppConfig()
diff --git a/src/ServiceControlInstaller.Engine/Instances/TransportInfo.cs b/src/ServiceControlInstaller.Engine/Instances/TransportInfo.cs
index 1afd71a489..86b1fbf33a 100644
--- a/src/ServiceControlInstaller.Engine/Instances/TransportInfo.cs
+++ b/src/ServiceControlInstaller.Engine/Instances/TransportInfo.cs
@@ -6,14 +6,21 @@
public class TransportInfo
{
public string Name { get; set; }
+
public string DisplayName { get; set; }
+
public string TypeName { get; set; }
+
public string SampleConnectionString { get; set; }
+
public string Help { get; set; }
- public bool Default { get; set; }
+
public bool AvailableInSCMU { get; set; } = true;
+
public bool Removed { get; set; }
+
public string AutoMigrateTo { get; set; }
+
public string[] Aliases { get; set; } = Array.Empty();
public string ZipName
diff --git a/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackageTests.cs b/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackageTests.cs
index fd9df54d2a..8fd926477a 100644
--- a/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackageTests.cs
+++ b/src/ServiceControlInstaller.Packaging.UnitTests/DeploymentPackageTests.cs
@@ -85,7 +85,7 @@ public void Should_package_all_transports()
"AzureServiceBus",
"NetStandardAzureServiceBus",
"RabbitMQ",
- //"MSMQ", TODO Uncomment when we add MSMQ back in
+ "MSMQ",
"AmazonSQS",
"LearningTransport"};