Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

📋 Description

Adds .NET Aspire as an alternative orchestration method for Chapter 3's microservices architecture. Provides service orchestration, built-in observability, and automatic dependency management while maintaining full backward compatibility with existing docker-compose setup.

New Projects

  • Fitnet.AppHost: Orchestrates PostgreSQL, RabbitMQ, Fitnet monolith, and Contracts microservice
  • Fitnet.ServiceDefaults: Shared library for OpenTelemetry, service discovery, health checks, and HTTP resilience

Connection String Pattern

All database and messaging modules now prioritize Aspire connection strings with fallback to legacy configuration:

// EventBusModule.cs - RabbitMQ
var connectionString = configuration.GetConnectionString("rabbitmq");
if (!string.IsNullOrEmpty(connectionString))
{
    factoryConfigurator.Host(new Uri(connectionString));
}
else
{
    // Fallback to EventBusOptions
    factoryConfigurator.Host(options.Value.Uri, ...);
}
// DatabaseModule.cs - PostgreSQL
var connectionString = configuration.GetConnectionString("fitnet");
if (string.IsNullOrEmpty(connectionString))
{
    connectionString = databaseOptions.Value.ConnectionString;
}
options.UseNpgsql(connectionString);

Service Integration

// Program.cs
builder.AddServiceDefaults();  // OpenTelemetry, service discovery, resilience
app.MapDefaultEndpoints();     // /health and /alive endpoints

AppHost Configuration

var postgres = builder.AddPostgres("postgres")
    .WithImage("postgres").WithImageTag("14.3")
    .WithHealthCheck();

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

builder.AddProject<Projects.Fitnet>("fitnet-modular-monolith")
    .WithReference(postgres.AddDatabase("fitnet"))
    .WithReference(rabbitmq);

Usage

cd Fitnet.AppHost && dotnet run

Aspire Dashboard provides unified view of services, traces, metrics, and logs. Applications remain accessible at ports 8080 (Fitnet) and 8081 (Contracts).

📦 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

Files Modified: 10 (connection string handling in DatabaseModule/EventBusModule across all modules, Program.cs integration)
Files Created: 6 (AppHost, ServiceDefaults, documentation)
Stats: +621/-16 lines

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

See Docs/ASPIRE_IMPLEMENTATION.md for architecture details and implementation patterns.

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 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
Copilot finished work on behalf of kamilbaczek November 20, 2025 18:06
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