Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/NServiceBus.Core/Receiving/ReceiveComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ public static ReceiveComponent Configure(
hostingConfiguration.Services.AddSingleton(messageHandlerRegistry);
foreach (var messageType in messageHandlerRegistry.GetMessageTypes())
{
handlerDiagnostics[messageType.FullName!] = messageHandlerRegistry.GetHandlersFor(messageType)
.Select(handler => handler.HandlerType.FullName!)
.ToList();
handlerDiagnostics[messageType.FullName!] = [.. messageHandlerRegistry.GetHandlersFor(messageType).Select(handler => handler.HandlerType.FullName!)];
}

var receiveSettings = new List<ReceiveSettings>
Expand Down Expand Up @@ -149,6 +147,23 @@ public async Task Initialize(
return;
}

// Resolving the logger here with the LogManager for now since we want to do a consistent sweep of all LogManager usage
// in the next minor when GetLogger might be deprecated. But we do it late when the service provider is available
// to make sure the logger is already properly wired up.
var logger = LogManager.GetLogger<MessageHandlerRegistry>();
if (logger.IsDebugEnabled)
{
var messageHandlerRegistry = configuration.MessageHandlerRegistry;
foreach (var messageType in messageHandlerRegistry.GetMessageTypes())
{
var handlers = messageHandlerRegistry.GetHandlersFor(messageType);
foreach (var messageHandler in handlers)
{
logger.DebugFormat("Associated '{0}' message with '{1}' {2} handler.", messageType, messageHandler.HandlerType, messageHandler.IsTimeoutHandler ? "timeout" : "message");
}
}
}

var mainProcessingLogSlot = CreateReceiverProcessingLogSlot(endpointLogSlot, MainReceiverId);
var mainPump = CreateReceiver(consecutiveFailuresConfiguration, transportInfrastructure.Receivers[MainReceiverId], mainProcessingLogSlot);

Expand Down
4 changes: 0 additions & 4 deletions src/NServiceBus.Core/Unicast/MessageHandlerRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Logging;
using Microsoft.Extensions.DependencyInjection;
using Particular.Obsoletes;
using Pipeline;
Expand Down Expand Up @@ -124,7 +123,6 @@ public void AddHandler<THandler>()
return;
}

Log.DebugFormat("Associated '{0}' message with '{1}' message handler.", typeof(TMessage), typeof(THandler));
var handlerFactories = GetOrCreate<THandler>();
handlerFactories.Add(new MessageHandlerFactory<THandlerAdapter, TMessage, THandler>());
}
Expand All @@ -141,7 +139,6 @@ public void AddHandler<THandler>()
return;
}

Log.DebugFormat("Associated '{0}' message with '{1}' timeout handler.", typeof(TMessage), typeof(THandler));
var handlerFactories = GetOrCreate<THandler>();
handlerFactories.Add(new TimeoutHandlerFactory<THandler, TMessage>());
}
Expand Down Expand Up @@ -213,7 +210,6 @@ void AddHandlerWithReflection(Type handlerType) =>
readonly Dictionary<Type, List<IMessageHandlerFactory>> messageHandlerFactories = [];
readonly HashSet<HandlerAndMessage> deduplicationSet = [];
static readonly Type IHandleMessagesType = typeof(IHandleMessages<>);
static readonly ILog Log = LogManager.GetLogger<MessageHandlerRegistry>();

internal const string TrimmingMessage = "Registering handlers using assembly scanning is not supported in trimming scenarios.";

Expand Down
Loading