Skip to content

Commit

Permalink
Make monitoring not need timeout infrastructure on MSMQ (#3504) (#3510)
Browse files Browse the repository at this point in the history
* Add test for service control

* Centralize default endpoint configuration

* Update approvals for transport configuration

* Remove unneeded test config

* Use unique name for test error queue

* Use sanitizer for ASQ

* Move sanitization to ConfigureTransport method

* Call CreateTestQueue instead of ProvisionQueues

* Remove unused feature configuration code

* Use CreateTestQueue instead of ProvisionQueues

* Make queue creation explicit in tests

* Remove UsePersistence call

* Use explicit persistence in tests

---------

Co-authored-by: williambza <william.brander@gmail.com>
  • Loading branch information
andreasohlund and WilliamBZA authored May 5, 2023
1 parent f3ffced commit de58976
Show file tree
Hide file tree
Showing 19 changed files with 190 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public override Task ProvisionQueues(string username, TransportSettings transpor

public override IProvideQueueLength CreateQueueLengthProvider() => throw new System.NotImplementedException();
public override void CustomizeForReturnToSenderIngestion(RawEndpointConfiguration endpointConfiguration, TransportSettings transportSettings) => throw new System.NotImplementedException();
public override void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings) => throw new System.NotImplementedException();
public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings) => throw new System.NotImplementedException();
public override void CustomizeServiceControlEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings) => throw new System.NotImplementedException();
protected override void CustomizeTransportSpecificMonitoringEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings) => throw new System.NotImplementedException();
protected override void CustomizeTransportSpecificSendOnlyEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings) => throw new System.NotImplementedException();
protected override void CustomizeTransportSpecificServiceControlEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings) => throw new System.NotImplementedException();
protected override void CustomizeForQueueIngestion(RawEndpointConfiguration endpointConfiguration, TransportSettings transportSettings) => throw new System.NotImplementedException();
protected override void CustomizeRawSendOnlyEndpoint(RawEndpointConfiguration endpointConfiguration, TransportSettings transportSettings) => throw new System.NotImplementedException();
}
Expand Down
8 changes: 0 additions & 8 deletions src/ServiceControl.Audit/Infrastructure/NServiceBusFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace ServiceControl.Audit.Infrastructure
using Contracts.MessageFailures;
using NServiceBus;
using NServiceBus.Configuration.AdvancedExtensibility;
using NServiceBus.Features;
using Settings;
using Transports;

Expand All @@ -27,11 +26,7 @@ public static void Configure(Settings.Settings settings, TransportCustomization

configuration.GetSettings().Set("ServiceControl.Settings", settings);

configuration.SendOnly();

transportCustomization.CustomizeSendOnlyEndpoint(configuration, transportSettings);
//DisablePublishing API is available only on TransportExtensions for transports that implement IMessageDrivenPubSub so we need to set settings directly
configuration.GetSettings().Set("NServiceBus.PublishSubscribe.EnablePublishing", false);

var serviceControlLogicalQueue = settings.ServiceControlQueueAddress;
if (!string.IsNullOrWhiteSpace(serviceControlLogicalQueue))
Expand All @@ -54,9 +49,6 @@ public static void Configure(Settings.Settings settings, TransportCustomization
configuration.GetSettings().Set(loggingSettings);
configuration.SetDiagnosticsPath(loggingSettings.LogPath);

// sagas are not auto-disabled for send-only endpoints
configuration.DisableFeature<Sagas>();

configuration.UseSerialization<NewtonsoftJsonSerializer>();

configuration.Conventions().DefiningEventsAs(t => typeof(IEvent).IsAssignableFrom(t) || IsExternalContract(t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected override void CustomizeForQueueIngestion(RawEndpointConfiguration endp
CustomizeRawEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificMonitoringEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}
Expand All @@ -30,12 +30,12 @@ protected override void CustomizeRawSendOnlyEndpoint(RawEndpointConfiguration en
CustomizeRawEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificSendOnlyEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeServiceControlEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificServiceControlEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.SendsAtomicWithReceive);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
namespace ServiceControl.Transports.ASB
{
using System;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.Raw;
using NServiceBus.Transport;

public class ASBForwardingTopologyTransportCustomization : TransportCustomization
{
Expand All @@ -18,7 +15,7 @@ protected override void CustomizeForQueueIngestion(RawEndpointConfiguration endp
CustomizeRawEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificMonitoringEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}
Expand All @@ -33,12 +30,12 @@ protected override void CustomizeRawSendOnlyEndpoint(RawEndpointConfiguration en
CustomizeRawEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificSendOnlyEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeServiceControlEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificServiceControlEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.SendsAtomicWithReceive);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
namespace ServiceControl.Transports.ASBS
{
using System;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.Raw;
using NServiceBus.Transport;

public class ASBSTransportCustomization : TransportCustomization
{
Expand All @@ -15,7 +12,7 @@ protected override void CustomizeForQueueIngestion(RawEndpointConfiguration endp
CustomizeEndpoint(transport, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificMonitoringEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();

Expand All @@ -29,7 +26,7 @@ public override void CustomizeForReturnToSenderIngestion(RawEndpointConfiguratio
CustomizeEndpoint(transport, transportSettings, TransportTransactionMode.SendsAtomicWithReceive);
}

public override void CustomizeServiceControlEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificServiceControlEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();

Expand All @@ -43,7 +40,7 @@ protected override void CustomizeRawSendOnlyEndpoint(RawEndpointConfiguration en
CustomizeEndpoint(transport, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificSendOnlyEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();

Expand Down
11 changes: 5 additions & 6 deletions src/ServiceControl.Transports.ASQ/ASQTransportCustomization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
{
using NServiceBus;
using NServiceBus.Raw;
using NServiceBus.Transport;
using System;
using System.Threading.Tasks;

public class ASQTransportCustomization : TransportCustomization
{
Expand All @@ -14,7 +12,7 @@ protected override void CustomizeForQueueIngestion(RawEndpointConfiguration endp
CustomizeRawEndpoint(endpointConfiguration, transportSettings);
}

public override void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificMonitoringEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings);
}
Expand All @@ -24,7 +22,7 @@ public override void CustomizeForReturnToSenderIngestion(RawEndpointConfiguratio
CustomizeRawEndpoint(endpointConfiguration, transportSettings);
}

public override void CustomizeServiceControlEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificServiceControlEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
var transport = CustomizeEndpoint(endpointConfiguration, transportSettings);
transport.EnableMessageDrivenPubSubCompatibilityMode();
Expand All @@ -35,7 +33,7 @@ protected override void CustomizeRawSendOnlyEndpoint(RawEndpointConfiguration en
CustomizeRawEndpoint(endpointConfiguration, transportSettings);
}

public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificSendOnlyEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings);
//Do not ConfigurePubSub for send-only endpoint
Expand All @@ -44,6 +42,7 @@ public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointCon
static TransportExtensions<AzureStorageQueueTransport> CustomizeEndpoint(EndpointConfiguration endpointConfig, TransportSettings transportSettings)
{
var transport = endpointConfig.UseTransport<AzureStorageQueueTransport>();

ConfigureTransport(transport, transportSettings);
return transport;
}
Expand All @@ -60,9 +59,9 @@ static void ConfigureTransport(TransportExtensions<AzureStorageQueueTransport> t
var connectionString = transportSettings.ConnectionString
.RemoveCustomConnectionStringParts(out var subscriptionTableName);

transport.SanitizeQueueNamesWith(BackwardsCompatibleQueueNameSanitizer.Sanitize);
transport.Transactions(TransportTransactionMode.ReceiveOnly);
transport.ConnectionString(connectionString);
transport.SanitizeQueueNamesWith(BackwardsCompatibleQueueNameSanitizer.Sanitize);

if (!string.IsNullOrEmpty(subscriptionTableName))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
namespace ServiceControl.Transports.Learning
{
using System;
using System.Threading.Tasks;
using LearningTransport;
using NServiceBus;
using NServiceBus.Raw;
using NServiceBus.Transport;

public class LearningTransportCustomization : TransportCustomization
{
public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificSendOnlyEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeServiceControlEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificServiceControlEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.SendsAtomicWithReceive);
}
Expand All @@ -29,7 +27,7 @@ protected override void CustomizeForQueueIngestion(RawEndpointConfiguration endp
CustomizeRawEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificMonitoringEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, TransportTransactionMode.ReceiveOnly);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
namespace ServiceControl.Transports.Msmq
{
using System;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.Raw;
using NServiceBus.Transport;

public class MsmqTransportCustomization : TransportCustomization
{
public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificSendOnlyEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, TransportTransactionMode.ReceiveOnly);
}

public override void CustomizeServiceControlEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificServiceControlEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, TransportTransactionMode.SendsAtomicWithReceive);
}
Expand All @@ -29,7 +26,7 @@ protected override void CustomizeForQueueIngestion(RawEndpointConfiguration endp
transport.IgnoreIncomingTimeToBeReceivedHeaders();
}

public override void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificMonitoringEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, TransportTransactionMode.ReceiveOnly);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
namespace ServiceControl.Transports.RabbitMQ
{
using System.Threading.Tasks;
using System;
using NServiceBus;
using NServiceBus.Raw;
using NServiceBus.Transport;

public abstract class RabbitMQConventionalRoutingTransportCustomization : TransportCustomization
{
Expand All @@ -15,12 +12,12 @@ protected RabbitMQConventionalRoutingTransportCustomization(QueueType queueType)
this.queueType = queueType;
}

public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificSendOnlyEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, queueType);
}

public override void CustomizeServiceControlEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificServiceControlEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, queueType);
}
Expand All @@ -35,7 +32,7 @@ protected override void CustomizeForQueueIngestion(RawEndpointConfiguration endp
CustomizeRawEndpoint(endpointConfiguration, transportSettings, queueType);
}

public override void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificMonitoringEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, queueType);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
namespace ServiceControl.Transports.RabbitMQ
{
using System.Threading.Tasks;
using System;
using NServiceBus;
using NServiceBus.Raw;
using NServiceBus.Transport;

public abstract class RabbitMQDirectRoutingTransportCustomization : TransportCustomization
{
Expand All @@ -15,12 +12,12 @@ protected RabbitMQDirectRoutingTransportCustomization(QueueType queueType)
this.queueType = queueType;
}

public override void CustomizeSendOnlyEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificSendOnlyEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, queueType);
}

public override void CustomizeServiceControlEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificServiceControlEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, queueType);
}
Expand All @@ -35,7 +32,7 @@ protected override void CustomizeForQueueIngestion(RawEndpointConfiguration endp
CustomizeRawEndpoint(endpointConfiguration, transportSettings, queueType);
}

public override void CustomizeMonitoringEndpoint(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
protected override void CustomizeTransportSpecificMonitoringEndpointSettings(EndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
{
CustomizeEndpoint(endpointConfiguration, transportSettings, queueType);
}
Expand Down
Loading

0 comments on commit de58976

Please sign in to comment.