Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue 253 add active mq hosting #273

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c1b38c3
#253 start with ActiveMQ hosting
anoordover Nov 19, 2024
a8f125d
#253 Add activemq hosting with example using MassTransit
anoordover Nov 19, 2024
d8edac8
#253 added unittest and README.md
anoordover Nov 19, 2024
061e652
Update examples/activemq/CommunityToolkit.Aspire.Hosting.ActiveMQ.App…
anoordover Nov 20, 2024
1ee3d99
Update examples/activemq/CommunityToolkit.Aspire.Hosting.ActiveMQ.App…
anoordover Nov 20, 2024
9502d87
Update examples/activemq/CommunityToolkit.Aspire.Hosting.ActiveMQ.Mas…
anoordover Nov 20, 2024
215ddda
#253 resolved comments
anoordover Nov 20, 2024
f86f9d3
Update examples/activemq/CommunityToolkit.Aspire.Hosting.ActiveMQ.Ser…
anoordover Nov 20, 2024
5c5d418
Update src/CommunityToolkit.Aspire.Hosting.ActiveMQ/ActiveMQBuilderEx…
anoordover Nov 20, 2024
b02028c
Update src/CommunityToolkit.Aspire.Hosting.ActiveMQ/ActiveMQBuilderEx…
anoordover Nov 20, 2024
62fae87
Update src/CommunityToolkit.Aspire.Hosting.ActiveMQ/ActiveMQBuilderEx…
anoordover Nov 20, 2024
15edf1f
Update src/CommunityToolkit.Aspire.Hosting.ActiveMQ/ActiveMQBuilderEx…
anoordover Nov 20, 2024
c7a6f5f
Update src/CommunityToolkit.Aspire.Hosting.ActiveMQ/ActiveMQBuilderEx…
anoordover Nov 20, 2024
337c187
Update src/CommunityToolkit.Aspire.Hosting.ActiveMQ/ActiveMQBuilderEx…
anoordover Nov 20, 2024
0599a43
#253 added AppHostTests for ActiveMQ
anoordover Nov 20, 2024
069d789
#253 masstransit alive added to example
anoordover Nov 20, 2024
5730deb
#253 added healthcheck to the MassTransit application, added a counte…
anoordover Nov 21, 2024
f463fe1
Update src/CommunityToolkit.Aspire.Hosting.ActiveMQ/ActiveMQServerRes…
anoordover Nov 22, 2024
02ee739
#253 changed consumer to Request/Response
anoordover Nov 22, 2024
51029ba
#253 added healthcheck first iteration
anoordover Nov 22, 2024
7736cb6
#253 merge two methods and remove parameters from method
anoordover Nov 22, 2024
581823e
#253 added MassTransit to the meters.
anoordover Nov 22, 2024
ef2ab98
Merge branch 'main' into feature/issue_253_AddActiveMqHosting
aaronpowell Nov 24, 2024
655e2fd
Merge branch 'main' into feature/issue_253_AddActiveMqHosting
anoordover Nov 26, 2024
6bb2bc7
Merge branch 'main' into feature/issue_253_AddActiveMqHosting
anoordover Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions CommunityToolkit.Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hos
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Bun.Tests", "tests\CommunityToolkit.Aspire.Hosting.Bun.Tests\CommunityToolkit.Aspire.Hosting.Bun.Tests.csproj", "{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.ActiveMQ", "src\CommunityToolkit.Aspire.Hosting.ActiveMQ\CommunityToolkit.Aspire.Hosting.ActiveMQ.csproj", "{56C3C409-10FF-4CA5-99AD-0D35C5418B2A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "activemq", "activemq", "{BF4C4E57-DAAF-4EE5-B330-1923106BAE69}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.ActiveMQ.AppHost", "examples\activemq\CommunityToolkit.Aspire.Hosting.ActiveMQ.AppHost\CommunityToolkit.Aspire.Hosting.ActiveMQ.AppHost.csproj", "{CF6CF1C3-EBE1-41CE-9B34-0C2F931AEA12}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.ActiveMQ.ServiceDefaults", "examples\activemq\CommunityToolkit.Aspire.Hosting.ActiveMQ.ServiceDefaults\CommunityToolkit.Aspire.Hosting.ActiveMQ.ServiceDefaults.csproj", "{978EED2A-43BB-4DE6-8563-3A9972869661}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit", "examples\activemq\CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit\CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit.csproj", "{A87F7800-BD24-4577-8F15-50D33C8DACF1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.ActiveMQ.Tests", "tests\CommunityToolkit.Aspire.Hosting.ActiveMQ.Tests\CommunityToolkit.Aspire.Hosting.ActiveMQ.Tests.csproj", "{1200FB2E-F476-4151-BDFD-1DAEE3E99FF5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -371,6 +383,26 @@ Global
{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A}.Release|Any CPU.Build.0 = Release|Any CPU
{56C3C409-10FF-4CA5-99AD-0D35C5418B2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56C3C409-10FF-4CA5-99AD-0D35C5418B2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56C3C409-10FF-4CA5-99AD-0D35C5418B2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56C3C409-10FF-4CA5-99AD-0D35C5418B2A}.Release|Any CPU.Build.0 = Release|Any CPU
{CF6CF1C3-EBE1-41CE-9B34-0C2F931AEA12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF6CF1C3-EBE1-41CE-9B34-0C2F931AEA12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF6CF1C3-EBE1-41CE-9B34-0C2F931AEA12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF6CF1C3-EBE1-41CE-9B34-0C2F931AEA12}.Release|Any CPU.Build.0 = Release|Any CPU
{978EED2A-43BB-4DE6-8563-3A9972869661}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{978EED2A-43BB-4DE6-8563-3A9972869661}.Debug|Any CPU.Build.0 = Debug|Any CPU
{978EED2A-43BB-4DE6-8563-3A9972869661}.Release|Any CPU.ActiveCfg = Release|Any CPU
{978EED2A-43BB-4DE6-8563-3A9972869661}.Release|Any CPU.Build.0 = Release|Any CPU
{A87F7800-BD24-4577-8F15-50D33C8DACF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A87F7800-BD24-4577-8F15-50D33C8DACF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A87F7800-BD24-4577-8F15-50D33C8DACF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A87F7800-BD24-4577-8F15-50D33C8DACF1}.Release|Any CPU.Build.0 = Release|Any CPU
{1200FB2E-F476-4151-BDFD-1DAEE3E99FF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1200FB2E-F476-4151-BDFD-1DAEE3E99FF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1200FB2E-F476-4151-BDFD-1DAEE3E99FF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1200FB2E-F476-4151-BDFD-1DAEE3E99FF5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -444,6 +476,12 @@ Global
{A7614F2B-E810-412E-91E7-8B6272DD5DBB} = {8519CC01-1370-47C8-AD94-B0F326B1563F}
{36FC2579-582A-4DAF-9B20-AB33331624C6} = {A7614F2B-E810-412E-91E7-8B6272DD5DBB}
{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{56C3C409-10FF-4CA5-99AD-0D35C5418B2A} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
{BF4C4E57-DAAF-4EE5-B330-1923106BAE69} = {8519CC01-1370-47C8-AD94-B0F326B1563F}
{CF6CF1C3-EBE1-41CE-9B34-0C2F931AEA12} = {BF4C4E57-DAAF-4EE5-B330-1923106BAE69}
{978EED2A-43BB-4DE6-8563-3A9972869661} = {BF4C4E57-DAAF-4EE5-B330-1923106BAE69}
{A87F7800-BD24-4577-8F15-50D33C8DACF1} = {BF4C4E57-DAAF-4EE5-B330-1923106BAE69}
{1200FB2E-F476-4151-BDFD-1DAEE3E99FF5} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {08B1D4B8-D2C5-4A64-BB8B-E1A2B29525F0}
Expand Down
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
<!-- External packages -->
<PackageVersion Include="JsonSchema.Net" Version="7.2.3" />
<PackageVersion Include="OllamaSharp" Version="4.0.8" />
<PackageVersion Include="MassTransit" Version="8.3.1" />
<PackageVersion Include="MassTransit.ActiveMQ" Version="8.3.1" />
<PackageVersion Include="MeiliSearch" Version="0.15.4" />
<PackageVersion Include="Microsoft.SqlServer.DacFx" Version="162.5.57" />
<PackageVersion Include="Microsoft.Build" Version="17.11.4" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="$(AspireAppHostSdkVersion)" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>cb846a57-bdaf-4abd-a7fb-0299aa095f5e</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" />
<PackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Hosting.ActiveMQ\CommunityToolkit.Aspire.Hosting.ActiveMQ.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit\CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.Extensions.DependencyInjection;
using Projects;

var builder = DistributedApplication.CreateBuilder(args);

var username = builder.AddParameter("user", "admin");
var password = builder.AddParameter("password", "admin", secret: true);

var amq = builder.AddActiveMQ("amq", username, password, 61616, "activemq", webPort: 8161)
.PublishAsConnectionString();

builder.AddProject<CommunityToolkit_Aspire_Hosting_ActiveMQ_MassTransit>("masstransitExample")
.WithReference(amq)
.WithHttpHealthCheck(path: "/health")
.WaitFor(amq);

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17276;http://localhost:15246",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21269",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22000"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15246",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19099",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20012"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MassTransit" />
<PackageReference Include="MassTransit.ActiveMQ" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.ActiveMQ.ServiceDefaults\CommunityToolkit.Aspire.Hosting.ActiveMQ.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit_HostAddress = http://localhost:5004

POST http://localhost:5004/send/Hello%20World
Accept: application/json

###
GET http://localhost:5004/alive
Accept: application/json

###
GET http://localhost:5004/received
Accept: application/json

###
GET http://admin:admin@localhost:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,service=Health/CurrentStatus
origin: localhost

###
GET http://localhost:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,service=Health/CurrentStatus
origin: localhost
Authorization: Basic YWRtaW46YWRtaW4=
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using MassTransit;

namespace CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit;

public class HelloWorldConsumer(ILogger<HelloWorldConsumer> logger, MessageCounter messageCounter) : IConsumer<Message>
{
public async Task Consume(ConsumeContext<Message> context)
{
logger.LogInformation("Received message: {Text}", context.Message.Text);
messageCounter.ReceivedMessages++;
await context.RespondAsync<MessageReply>(new
{
Reply = "I've received your message: " + context.Message.Text
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit;

public record Message
{
public required string Text { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit;

public class MessageCounter
{
public int ReceivedMessages { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit;

public record MessageReply
{
public required string Reply { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit;
using MassTransit;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();
builder.Services
.AddSingleton(KebabCaseEndpointNameFormatter.Instance)
.AddSingleton<MessageCounter>();
builder.Services.AddMassTransit(x =>
{
x.UsingActiveMq((context, cfg) =>
{
string connectionString = builder.Configuration.GetConnectionString("amq")!;
cfg.ConfigureEndpoints(context, new KebabCaseEndpointNameFormatter("aspire", false));
cfg.Host(new Uri(connectionString), _ => {});
});
x.AddConsumers(typeof(HelloWorldConsumer).Assembly);
});

WebApplication app = builder.Build();

app.MapPost("/send/{text}", async (string text,
[FromServices] IRequestClient<Message> requestClient,
[FromServices] ILogger<Program> logger) =>
{
logger.LogInformation("Send message: {Text}", text);
Response<MessageReply> response = await requestClient.GetResponse<MessageReply>(new { Text = text });
logger.LogInformation("Sent message: {Text}", text);
return response.Message.Reply;
})
.WithName("SendMessage");

app.MapGet("/received", ([FromServices] MessageCounter messageCounter) => messageCounter)
.WithName("ReceivedMessages");

app.MapDefaultEndpoints();
app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5004",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7038;http://localhost:5004",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ConnectionStrings": {
"amq": "activemq://localhost:61616"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
</ItemGroup>

</Project>
Loading
Loading