Skip to content

Feature 030: Generic messaging infrastructure cleanup#37

Merged
ovation22 merged 1 commit intomainfrom
feature/030-generic-messaging-cleanup
Apr 8, 2026
Merged

Feature 030: Generic messaging infrastructure cleanup#37
ovation22 merged 1 commit intomainfrom
feature/030-generic-messaging-cleanup

Conversation

@ovation22
Copy link
Copy Markdown
Owner

Summary

  • Extract RabbitMqConnectionStringParser — eliminates duplicated connection string parsing logic that existed independently in both RabbitMqBrokerAdapter and RabbitMqMessagePublisher
  • Simplify GenericMessageConsumer.BuildConfiguration() — cuts seven connection string fallback keys down to two canonical Aspire-injected keys (ConnectionStrings:messaging for RabbitMQ, ConnectionStrings:servicebus for Azure Service Bus)
  • Cache ServiceBusSender in AzureServiceBusPublisher — sender instances are now reused per destination queue via ConcurrentDictionary instead of being created on every publish call
  • Document ServiceBusBrokerAdapter deferred-connection behaviour — clarifies in XML docs that ConnectAsync configures the processor but does not open a connection (an SDK constraint); IMessageBrokerAdapter.ConnectAsync updated to describe both the eager (RabbitMQ) and deferred (Service Bus) models
  • Add AddMessageConsumer extension 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 and AddMessageConsumer<TMessage, TProcessor, TWorker>() for named hosted services
  • Add MessageConsumerWorker<TMessage, TProcessor> — consolidates identical BackgroundService lifecycle logic (start, keep-alive, stop, dispose) that was duplicated across all four microservice Worker.cs files
  • Slim down each microservice Worker.cs — each Worker is now a one-liner subclass of MessageConsumerWorker, preserving named log output (Worker appears in logs rather than the generic type name) and providing a customisation point for future service-specific needs
  • Remove MessagePublisherExtensions — backward-compatibility shim had no callers; deleted

Test plan

  • All 792 unit tests pass
  • Build succeeds with no errors
  • Each microservice Program.cs uses AddMessageConsumer<TMessage, TProcessor, Worker>() as its sole consumer registration call
  • Verify RabbitMQ consumer connection strings resolve correctly in local Aspire dev environment (ConnectionStrings:messaging)

- 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)
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Test Results

746 tests  ±0   746 ✅ ±0   6s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 28affbd. ± Comparison against base commit 67c47ca.

@ovation22 ovation22 merged commit 52ce51f into main Apr 8, 2026
2 checks passed
@ovation22 ovation22 deleted the feature/030-generic-messaging-cleanup branch April 8, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant