Skip to content

Commit 1aa0e8c

Browse files
authored
Enable saga and message audit to the .NET Aspire demo (#7591)
* Enabled message audit on all endpoints and saga audit where applicable. * Updated the .NET 10 aspire sample with auditing * Updated to use the default audit queue * Added RabbitMQ default management login credentials
1 parent 321be38 commit 1aa0e8c

File tree

14 files changed

+28
-2
lines changed

14 files changed

+28
-2
lines changed

samples/hosting/aspire/Core_10/AspireDemo.AppHost/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
var builder = DistributedApplication.CreateBuilder(args);
66

7-
var transport = builder.AddRabbitMQ("transport")
7+
var rabbitUser = builder.AddParameterFromConfiguration("rabbitUser", "RabbitMQ:UserName", true);
8+
var rabbitPassword = builder.AddParameterFromConfiguration("rabbitPassword", "RabbitMQ:Password", true);
9+
10+
var transport = builder.AddRabbitMQ("transport", rabbitUser, rabbitPassword)
811
.WithManagementPlugin(15672)
912
.WithUrlForEndpoint("management", url => url.DisplayText = "RabbitMQ Management");
1013

samples/hosting/aspire/Core_10/AspireDemo.AppHost/appsettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
"Microsoft.AspNetCore": "Warning",
66
"Aspire.Hosting.Dcp": "Warning"
77
}
8+
},
9+
"RabbitMQ": {
10+
"UserName": "guest",
11+
"Password": "guest"
812
}
913
}

samples/hosting/aspire/Core_10/Billing/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
1616
endpointConfiguration.SendHeartbeatTo("Particular.ServiceControl");
17+
endpointConfiguration.AuditProcessedMessagesTo("audit");
1718

1819
var metrics = endpointConfiguration.EnableMetrics();
1920
metrics.SendMetricDataToServiceControl("Particular.Monitoring", TimeSpan.FromSeconds(1));

samples/hosting/aspire/Core_10/ClientUI/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
2020
endpointConfiguration.SendHeartbeatTo("Particular.ServiceControl");
21+
endpointConfiguration.AuditProcessedMessagesTo("audit");
2122

2223
var metrics = endpointConfiguration.EnableMetrics();
2324
metrics.SendMetricDataToServiceControl("Particular.Monitoring", TimeSpan.FromSeconds(1));

samples/hosting/aspire/Core_10/Sales/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
1616
endpointConfiguration.SendHeartbeatTo("Particular.ServiceControl");
17+
endpointConfiguration.AuditProcessedMessagesTo("audit");
1718

1819
var metrics = endpointConfiguration.EnableMetrics();
1920
metrics.SendMetricDataToServiceControl("Particular.Monitoring", TimeSpan.FromSeconds(1));

samples/hosting/aspire/Core_10/Shipping/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
4141
endpointConfiguration.SendHeartbeatTo("Particular.ServiceControl");
42+
endpointConfiguration.AuditProcessedMessagesTo("audit");
43+
endpointConfiguration.AuditSagaStateChanges(serviceControlQueue: "audit");
4244

4345
var metrics = endpointConfiguration.EnableMetrics();
4446
metrics.SendMetricDataToServiceControl("Particular.Monitoring", TimeSpan.FromSeconds(1));

samples/hosting/aspire/Core_10/Shipping/Shipping.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<PackageReference Include="NServiceBus.Metrics.ServiceControl" Version="6.0.0-alpha.1" />
2121
<PackageReference Include="NServiceBus.Persistence.Sql" Version="9.0.0-alpha.1" />
2222
<PackageReference Include="NServiceBus.RabbitMQ" Version="11.0.0-alpha.1" />
23+
<PackageReference Include="NServiceBus.SagaAudit" Version="6.0.0-alpha.1" />
2324
</ItemGroup>
2425

2526
</Project>

samples/hosting/aspire/Core_9/AspireDemo.AppHost/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
var builder = DistributedApplication.CreateBuilder(args);
66

7-
var transport = builder.AddRabbitMQ("transport")
7+
var rabbitUser = builder.AddParameterFromConfiguration("rabbitUser", "RabbitMQ:UserName", true);
8+
var rabbitPassword = builder.AddParameterFromConfiguration("rabbitPassword", "RabbitMQ:Password", true);
9+
10+
var transport = builder.AddRabbitMQ("transport", rabbitUser, rabbitPassword)
811
.WithManagementPlugin(15672)
912
.WithUrlForEndpoint("management", url => url.DisplayText = "RabbitMQ Management");
1013

samples/hosting/aspire/Core_9/AspireDemo.AppHost/appsettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
"Microsoft.AspNetCore": "Warning",
66
"Aspire.Hosting.Dcp": "Warning"
77
}
8+
},
9+
"RabbitMQ": {
10+
"UserName": "guest",
11+
"Password": "guest"
812
}
913
}

samples/hosting/aspire/Core_9/Billing/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
1616
endpointConfiguration.SendHeartbeatTo("Particular.ServiceControl");
17+
endpointConfiguration.AuditProcessedMessagesTo("audit");
1718

1819
var metrics = endpointConfiguration.EnableMetrics();
1920
metrics.SendMetricDataToServiceControl("Particular.Monitoring", TimeSpan.FromSeconds(1));

0 commit comments

Comments
 (0)