diff --git a/docs/guide/http/metadata.md b/docs/guide/http/metadata.md index 01d023cea..c7453bca4 100644 --- a/docs/guide/http/metadata.md +++ b/docs/guide/http/metadata.md @@ -204,3 +204,15 @@ public class ValidatedCompoundEndpoint2 ``` snippet source | anchor + +## With Microsoft.Extensions.ApiDescription.Server + +Just a heads up, if you are trying to use [Microsoft.Extensions.ApiDescription.Server](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/aspnetcore-openapi?view=aspnetcore-9.0&tabs=net-cli%2Cvisual-studio-code#generate-openapi-documents-at-build-time) and +you get an `ObjectDisposedException` error on compilation against the `IServiceProvider`, follow these steps to fix: + +1. Remove `Microsoft.Extensions.ApiDescription.Server` altogether +2. Just run `dotnet run` to see why your application isn't able to start correctly, and fix *that* problem +3. Add `Microsoft.Extensions.ApiDescription.Server` back + +For whatever reason, the source generator for OpenAPI tries to start the entire application, including Wolverine's +`IHostedService`, and the whole thing blows up with that very unhelpful message if anything is wrong with the application. diff --git a/src/Transports/AWS/WebAppWithSQS/Program.cs b/src/Transports/AWS/WebAppWithSQS/Program.cs new file mode 100644 index 000000000..50e2b2d5c --- /dev/null +++ b/src/Transports/AWS/WebAppWithSQS/Program.cs @@ -0,0 +1,46 @@ +using JasperFx; +using Wolverine; +using Wolverine.AmazonSqs; +using Wolverine.Http; +using Wolverine.RabbitMQ; +using Wolverine.Transports.Tcp; +using Wolverine.Util; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); + +builder.Services.AddWolverineHttp(); + +builder.Host.UseWolverine(opts => +{ + opts.UseAmazonSqsTransportLocally().AutoProvision(); + + opts.PublishMessage().ToSqsQueue("ext-logs"); + + opts.UseRabbitMq().AutoProvision(); + + opts.ListenAtPort(PortFinder.GetAvailablePort()); + + opts.ListenToRabbitQueue("foo"); +}); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseHttpsRedirection(); + +app.MapWolverineEndpoints(); + + +return await app.RunJasperFxCommands(args); + +public record ExtLog; + diff --git a/src/Transports/AWS/WebAppWithSQS/Properties/launchSettings.json b/src/Transports/AWS/WebAppWithSQS/Properties/launchSettings.json new file mode 100644 index 000000000..289cda844 --- /dev/null +++ b/src/Transports/AWS/WebAppWithSQS/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5065", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7261;http://localhost:5065", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Transports/AWS/WebAppWithSQS/WebAppWithSQS.csproj b/src/Transports/AWS/WebAppWithSQS/WebAppWithSQS.csproj new file mode 100644 index 000000000..6fb4effbe --- /dev/null +++ b/src/Transports/AWS/WebAppWithSQS/WebAppWithSQS.csproj @@ -0,0 +1,23 @@ + + + + net9.0 + enable + enable + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + diff --git a/src/Transports/AWS/WebAppWithSQS/WebAppWithSQS.http b/src/Transports/AWS/WebAppWithSQS/WebAppWithSQS.http new file mode 100644 index 000000000..abe04fcc6 --- /dev/null +++ b/src/Transports/AWS/WebAppWithSQS/WebAppWithSQS.http @@ -0,0 +1,6 @@ +@WebAppWithSQS_HostAddress = http://localhost:5065 + +GET {{WebAppWithSQS_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/src/Transports/AWS/WebAppWithSQS/appsettings.Development.json b/src/Transports/AWS/WebAppWithSQS/appsettings.Development.json new file mode 100644 index 000000000..0c208ae91 --- /dev/null +++ b/src/Transports/AWS/WebAppWithSQS/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/Transports/AWS/WebAppWithSQS/appsettings.json b/src/Transports/AWS/WebAppWithSQS/appsettings.json new file mode 100644 index 000000000..10f68b8c8 --- /dev/null +++ b/src/Transports/AWS/WebAppWithSQS/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/wolverine.sln b/wolverine.sln index 1753ef962..5da4bbfaf 100644 --- a/wolverine.sln +++ b/wolverine.sln @@ -279,6 +279,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiTenantedEfCoreWithPost EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiTenantedEfCoreWithSqlServer", "src\Persistence\MultiTenantedEfCoreWithSqlServer\MultiTenantedEfCoreWithSqlServer.csproj", "{F96DEAFA-C73E-4AF1-A858-E95E9EDB119F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAppWithSQS", "src\Transports\AWS\WebAppWithSQS\WebAppWithSQS.csproj", "{692321C4-1A3A-4603-A42F-36B86DC784DA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -712,6 +714,10 @@ Global {F96DEAFA-C73E-4AF1-A858-E95E9EDB119F}.Debug|Any CPU.Build.0 = Debug|Any CPU {F96DEAFA-C73E-4AF1-A858-E95E9EDB119F}.Release|Any CPU.ActiveCfg = Release|Any CPU {F96DEAFA-C73E-4AF1-A858-E95E9EDB119F}.Release|Any CPU.Build.0 = Release|Any CPU + {692321C4-1A3A-4603-A42F-36B86DC784DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {692321C4-1A3A-4603-A42F-36B86DC784DA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {692321C4-1A3A-4603-A42F-36B86DC784DA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {692321C4-1A3A-4603-A42F-36B86DC784DA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {24497E6A-D6B1-4C80-ABFB-57FFAD5070C4} = {96119B5E-B5F0-400A-9580-B342EBE26212} @@ -837,5 +843,6 @@ Global {3E83F8CE-A04A-477E-A103-1AC7CFDEBF0D} = {7A9E0EAE-9ABF-40F6-9DB9-8FB1243F4210} {11C936B6-A659-4CF3-851D-FFB339B351FA} = {7A9E0EAE-9ABF-40F6-9DB9-8FB1243F4210} {F96DEAFA-C73E-4AF1-A858-E95E9EDB119F} = {7A9E0EAE-9ABF-40F6-9DB9-8FB1243F4210} + {692321C4-1A3A-4603-A42F-36B86DC784DA} = {ABE5F332-6709-4EDF-B88A-39DB96542B18} EndGlobalSection EndGlobal