Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

📋 Description

Adds .NET Aspire orchestration for Chapter 3's microservices architecture, following the simplified pattern established in Chapter 2. Provides service orchestration for PostgreSQL and RabbitMQ while maintaining full backward compatibility with existing docker-compose setup.

New Project

  • Fitnet.AppHost: Orchestrates PostgreSQL, RabbitMQ, Fitnet modular monolith, and Contracts microservice using the same simplified pattern as Chapter 2

Central Package Management

Added Directory.Build.props and Directory.Packages.props at the Chapter 3 root level to centralize property and package version management, matching Chapter 2's approach:

  • Directory.Build.props: Defines common properties (TargetFramework, ImplicitUsings, Nullable)
  • Directory.Packages.props: Centralizes Aspire package versions (AppHost 13.0.0, PostgreSQL 13.0.0, RabbitMQ 13.0.0)

AppHost Configuration

The implementation follows Chapter 2's minimal approach with RabbitMQ added for Chapter 3's messaging requirements:

using Projects;

var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres")
    .WithImage("postgres", "14.3")
    .WithPgAdmin();

var fitnetDatabase = postgres.AddDatabase("fitnetsdb", "fitnet");

var rabbitmq = builder.AddRabbitMQ("rabbitmq")
    .WithManagementPlugin();

builder.AddProject<Fitnet>("fitnet-modular-monolith")
    .WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
    .WithReference(fitnetDatabase, "Database__ConnectionString")
    .WithReference(rabbitmq, "EventBus__ConnectionString")
    .WaitFor(postgres)
    .WaitFor(rabbitmq);

builder.AddProject<Fitnet_Contracts>("fitnet-contracts-microservice")
    .WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
    .WithReference(fitnetDatabase, "Database__ConnectionString")
    .WithReference(rabbitmq, "EventBus__ConnectionString")
    .WaitFor(postgres)
    .WaitFor(rabbitmq);

await builder.Build().RunAsync();

Usage

cd Fitnet.AppHost
dotnet run

The Aspire Dashboard will open automatically, showing all services, resources, and logs.

📦 PR Includes

  • Feature added 🆕
  • Bug fix 🐛
  • Code refactor 🔄
  • Documentation update 📚
  • Tests added/updated 🧪
  • Other: (describe)

🚫 PR Does Not Include

  • Breaking changes ❌
  • Major architectural changes 🏗️
  • Unrelated features/tasks 🚫

💡 Additional Notes

Simplified Implementation: Aligned with Chapter 2's approach by removing ServiceDefaults project and extensive documentation. The implementation now follows the same minimal pattern used in Chapter 2, including central package management via Directory props files.

Chapter 3 Specifics: Added RabbitMQ orchestration via AddRabbitMQ().WithManagementPlugin() to support the microservices messaging architecture.

Files Modified: 2 (EventBusModule.cs files for standard configuration)
Files Created: 4 (AppHost project files + Directory.Build.props + Directory.Packages.props)
Stats: +90/-559 lines (net reduction due to simplification)

Central Package Management: AppHost.csproj now inherits TargetFramework, ImplicitUsings, and Nullable from Directory.Build.props, and package versions from Directory.Packages.props - eliminating duplicate definitions and matching Chapter 2's pattern. Removed unnecessary project-specific .gitignore file from AppHost directory.

Version Conflict Fix: Upgraded Aspire packages from 9.0.0 to 13.0.0 to resolve NU1107 build error. The conflict was between MassTransit.RabbitMQ 8.3.2 (requiring RabbitMQ.Client >= 7.0.0) and Aspire.Hosting.RabbitMQ 9.0.0 (requiring RabbitMQ.Client < 7.0.0). Aspire 13.0.0 is compatible with RabbitMQ.Client 7.0.0, resolving the dependency conflict.

Fully backward compatible: docker-compose.yml workflow unchanged, services run with or without Aspire. No changes to Program.cs, business logic, or existing tests.

Original prompt

Aspire in chapter 3 implement rabbit mq in aspire


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits November 20, 2025 17:58
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
…ate README

Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement RabbitMQ in Aspire for chapter 3 Implement .NET Aspire orchestration in Chapter 3 with RabbitMQ and PostgreSQL Nov 20, 2025
Copilot AI requested a review from kamilbaczek November 20, 2025 18:06
@kamilbaczek
Copy link
Collaborator

I want to documentation and code be consistent with chapter 2 but we have more services here like rabbitmq remove unssery documentation and changes and align eto branch 'copilot/apply-aspire-in-chapter-2' @copilot

…viceDefaults

Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 9, 2025

I want to documentation and code be consistent with chapter 2 but we have more services here like rabbitmq remove unssery documentation and changes and align eto branch 'copilot/apply-aspire-in-chapte...

I've simplified the implementation to align with Chapter 2's approach:

Removed:

  • ServiceDefaults project entirely
  • Extensive ASPIRE_IMPLEMENTATION.md documentation
  • Complex connection string fallback patterns
  • ServiceDefaults references from Program.cs and project files

Simplified:

  • AppHost now matches Chapter 2's minimal pattern
  • README section reduced to essential steps
  • EventBusModule reverted to standard configuration pattern

Chapter 3 specific (RabbitMQ):

  • Added RabbitMQ orchestration via AddRabbitMQ().WithManagementPlugin()
  • Connection strings injected as EventBus__ConnectionString

The implementation is now consistent with Chapter 2 while adding RabbitMQ support for Chapter 3's microservices architecture. Commit: 2667c7d

@kamilbaczek
Copy link
Collaborator

@copilot net9.0
should be removed because it is in directory props defined

@kamilbaczek
Copy link
Collaborator

@copilot Chapter-3-microservice-extraction/Fitnet.AppHost/.gitignore remove this it is not used

Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 9, 2025

@copilot net9.0
should be removed because it is in directory props defined

Removed duplicate properties from AppHost.csproj and added central Directory.Build.props and Directory.Packages.props files at Chapter 3 root level. The AppHost now inherits TargetFramework, ImplicitUsings, and Nullable from Directory.Build.props, and package versions from Directory.Packages.props - matching Chapter 2's pattern. Commit: d7873b5

Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 9, 2025

@copilot Chapter-3-microservice-extraction/Fitnet.AppHost/.gitignore remove this it is not used

Removed the unnecessary .gitignore file from Fitnet.AppHost directory. Commit: 8ed0440

@kamilbaczek
Copy link
Collaborator

@copilot fix build problems

…lict

Co-authored-by: kamilbaczek <74410956+kamilbaczek@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot fix build problems

Fixed the build issue by upgrading Aspire packages from 9.0.0 to 13.0.0. This resolves the NU1107 version conflict where MassTransit.RabbitMQ 8.3.2 requires RabbitMQ.Client >= 7.0.0, which was incompatible with Aspire.Hosting.RabbitMQ 9.0.0 (requiring < 7.0.0). Aspire 13.0.0 is compatible with RabbitMQ.Client 7.0.0. Commit: 33b2159

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.

2 participants