|
8 | 8 | using System.Threading; |
9 | 9 | using System.Threading.Tasks; |
10 | 10 | using Microsoft.Extensions.DependencyInjection; |
| 11 | + using NServiceBus; |
11 | 12 | using NServiceBus.Logging; |
12 | 13 | using NServiceBus.Transport; |
13 | 14 | using NUnit.Framework; |
@@ -87,21 +88,24 @@ protected async Task<IAsyncDisposable> StartQueueLengthProvider(string queueName |
87 | 88 | // currently working around by creating a service collection per start call and then disposing the provider |
88 | 89 | // as part of the method scope. This could lead to potential problems later once we add disposable resources |
89 | 90 | // but this code probably requires a major overhaul anyway. |
90 | | - var serviceCollection = new ServiceCollection(); |
| 91 | + |
91 | 92 | var transportSettings = new TransportSettings |
92 | 93 | { |
93 | 94 | ConnectionString = configuration.ConnectionString, |
94 | 95 | EndpointName = queueName, |
95 | 96 | MaxConcurrency = 1 |
96 | 97 | }; |
| 98 | + |
| 99 | + var serviceCollection = new ServiceCollection(); |
| 100 | + |
97 | 101 | configuration.TransportCustomization.AddTransportForMonitoring(serviceCollection, transportSettings); |
98 | | - serviceCollection.AddSingleton<Action<QueueLengthEntry[], EndpointToQueueMapping>>((qlt, _) => |
99 | | - onQueueLengthReported(qlt.First())); |
| 102 | + configuration.TransportCustomization.CustomizeMonitoringEndpoint(new EndpointConfiguration("queueName"), transportSettings); |
| 103 | + |
| 104 | + serviceCollection.AddSingleton<Action<QueueLengthEntry[], EndpointToQueueMapping>>((qlt, _) => onQueueLengthReported(qlt.First())); |
100 | 105 | var serviceProvider = serviceCollection.BuildServiceProvider(); |
101 | | - queueLengthProvider = serviceProvider.GetRequiredService<IProvideQueueLength>(); |
102 | 106 |
|
| 107 | + queueLengthProvider = serviceProvider.GetRequiredService<IProvideQueueLength>(); |
103 | 108 | await queueLengthProvider.StartAsync(CancellationToken.None); |
104 | | - |
105 | 109 | queueLengthProvider.TrackEndpointInputQueue(new EndpointToQueueMapping(queueName, queueName)); |
106 | 110 |
|
107 | 111 | return new QueueLengthProviderScope(serviceProvider); |
|
0 commit comments