Feature 030: Generic messaging infrastructure cleanup#37
Merged
Conversation
- Extract RabbitMqConnectionStringParser to eliminate duplicated connection string parsing logic shared between RabbitMqBrokerAdapter and RabbitMqMessagePublisher - Simplify GenericMessageConsumer.BuildConfiguration() from seven connection string fallbacks to two canonical Aspire keys (ConnectionStrings:messaging and ConnectionStrings:servicebus) - Cache ServiceBusSender instances in AzureServiceBusPublisher to avoid per-publish sender creation overhead - Document ServiceBusBrokerAdapter.ConnectAsync deferred-connection behaviour and clarify the same in IMessageBrokerAdapter XML docs - Add AddMessageConsumer<TMessage, TProcessor>() and AddMessageConsumer<TMessage, TProcessor, TWorker>() extensions to MessageBusExtensions, replacing the three-line consumer registration pattern - Add MessageConsumerWorker<TMessage, TProcessor> base BackgroundService, consolidating identical Worker lifecycle logic from all four microservices - Replace each service Worker.cs with a thin one-liner subclass of MessageConsumerWorker, preserving named log output and customisation surface - Remove MessagePublisherExtensions backward-compatibility shim (no callers)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RabbitMqConnectionStringParser— eliminates duplicated connection string parsing logic that existed independently in bothRabbitMqBrokerAdapterandRabbitMqMessagePublisherGenericMessageConsumer.BuildConfiguration()— cuts seven connection string fallback keys down to two canonical Aspire-injected keys (ConnectionStrings:messagingfor RabbitMQ,ConnectionStrings:servicebusfor Azure Service Bus)ServiceBusSenderinAzureServiceBusPublisher— sender instances are now reused per destination queue viaConcurrentDictionaryinstead of being created on every publish callServiceBusBrokerAdapterdeferred-connection behaviour — clarifies in XML docs thatConnectAsyncconfigures the processor but does not open a connection (an SDK constraint);IMessageBrokerAdapter.ConnectAsyncupdated to describe both the eager (RabbitMQ) and deferred (Service Bus) modelsAddMessageConsumerextension methods — replaces the three-line consumer registration pattern (AddScoped+AddSingleton<IMessageConsumer>+AddHostedService) with a single call; two overloads provided:AddMessageConsumer<TMessage, TProcessor>()for template/simple use andAddMessageConsumer<TMessage, TProcessor, TWorker>()for named hosted servicesMessageConsumerWorker<TMessage, TProcessor>— consolidates identicalBackgroundServicelifecycle logic (start, keep-alive, stop, dispose) that was duplicated across all four microserviceWorker.csfilesWorker.cs— each Worker is now a one-liner subclass ofMessageConsumerWorker, preserving named log output (Workerappears in logs rather than the generic type name) and providing a customisation point for future service-specific needsMessagePublisherExtensions— backward-compatibility shim had no callers; deletedTest plan
AddMessageConsumer<TMessage, TProcessor, Worker>()as its sole consumer registration callConnectionStrings:messaging)