Back to Initiative Library
Infrastructure Medium complexity

RabbitMQ Migration Cleanup for .NET Services

✦ Sample Prompt
Remove leftover RabbitMQ code, config, and packages from every .NET service that
has already migrated to the new broker.

For each repository:
1. Confirm the service is migrated. The default signal: the `*.csproj` already
   references `MyOrg.NewBroker.Client` (configurable) and there are no remaining
   `IRabbit*` consumers wired in `Program.cs` / `Startup.cs`. If both conditions
   are not met, skip the repo and add it to a review list.
2. Remove from `*.csproj`:
   - `<PackageReference Include="RabbitMQ.Client" ... />`
   - Any internal wrapper packages listed in the prompt (e.g.,
     `MyOrg.Messaging.Rabbit`, `MyOrg.RabbitConsumer`)
3. Remove from `appsettings.json` / `appsettings.*.json`:
   - The `RabbitMQ` section (`ConnectionString`, `Exchange`, `Queue`, `VHost`, etc.)
   - Environment variables: `RABBITMQ_*`
4. Remove from `Startup.cs` / `Program.cs`:
   - `services.AddRabbitMq(...)`, `services.AddSingleton<IRabbitConnection>(...)`,
     and any `app.UseRabbit*` middleware registrations
5. Delete files under `Messaging/Rabbit/` (or equivalent folders) that are no
   longer referenced. If a file is still referenced anywhere in the repo, leave it
   and add to the triage list.
6. Do not touch test fixtures unless they only test deleted classes.

The Problem

After a messaging migration, the new broker code lands but the old RabbitMQ code rarely gets cleaned up immediately. The `RabbitMQ.Client` NuGet package, connection string config, and helper classes hang around (sometimes for years) confusing on-call engineers when they grep for "broker" and find two implementations.

The cleanup is straightforward (remove the package, delete dead classes, drop the connection string) but spans every migrated service and risks deleting code that’s still half-wired in a few edge cases.

What Tidra Does

  1. Detects services that already publish to the new broker (configurable signal: presence of the new client package)
  2. Removes the RabbitMQ.Client package and any internal wrapper packages from *.csproj
  3. Deletes the RabbitMQ connection string entries from appsettings*.json
  4. Removes the DI registration for the old client (services.AddRabbit...) from Startup.cs / Program.cs
  5. Skips services where RabbitMQ is still referenced in active code paths, with a list for human review

Before & After

diff
src/Service.csproj
@@ -10,7 +10,6 @@
<ItemGroup>
<PackageReference Include="MyOrg.NewBroker.Client" Version="2.4.0" />
- <PackageReference Include="RabbitMQ.Client" Version="6.8.1" />
</ItemGroup>
</Project>

Customization Tips

  • Detection signal: Provide the canonical "service has migrated" signal, typically the new client package reference or a feature flag.
  • Wrapper packages: If you have internal wrappers around RabbitMQ.Client, list them so Tidra removes them too.
  • Leftover references: Tidra refuses to delete code that is still referenced. The triage list captures those for owner review.

Ready to run this across your repos?

Connect your Git provider and Tidra opens pull requests in every repo that needs them.