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

Addressed an error with PostgreSQL transport configuration w/o an exp… #1179

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System.Diagnostics;
using IntegrationTests;
using JasperFx.Core;
using Marten;
using Marten.Storage;
using Microsoft.Extensions.Hosting;
using Oakton.Resources;
using Shouldly;
using Weasel.Core;
using Wolverine;
using Wolverine.Configuration;
using Wolverine.Marten;
using Wolverine.Postgresql;
using Wolverine.Tracking;

namespace MartenTests.Bugs;

public class Bug_1175_schema_name_with_queues
{
[Fact]
public async Task send_messages_with_postgresql_queueing()
{
using var sender = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
opts.ServiceName = "Service";

opts.ListenToPostgresqlQueue("response").MaximumParallelMessages(14, ProcessingOrder.UnOrdered);
opts.PublishMessage<ColorRequest>().ToPostgresqlQueue("request");

opts.Services.AddMarten(opt =>
{
opt.Connection(Servers.PostgresConnectionString);
opt.Events.TenancyStyle = TenancyStyle.Conjoined;
})
.UseLightweightSessions()
.IntegrateWithWolverine(options =>
{
options.AutoCreate = AutoCreate.CreateOrUpdate;
options.MessageStorageSchemaName = "sender";
});

opts.Services.AddResourceSetupOnStartup();

}).StartAsync();

using var listener = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
opts.ServiceName = "Listener";

opts.ListenToPostgresqlQueue("request").MaximumParallelMessages(14, ProcessingOrder.UnOrdered);
opts.PublishMessage<ColorResponse>().ToPostgresqlQueue("response");

opts.Services.AddMarten(opt =>
{
opt.Connection(Servers.PostgresConnectionString);
opt.Events.TenancyStyle = TenancyStyle.Conjoined;
})
.UseLightweightSessions()
.IntegrateWithWolverine(options =>
{
options.AutoCreate = AutoCreate.CreateOrUpdate;
options.MessageStorageSchemaName = "listener";
});

opts.Services.AddResourceSetupOnStartup();

}).StartAsync();

var tracked = await sender.TrackActivity().AlsoTrack(listener).SendMessageAndWaitAsync(new ColorRequest("red"));
tracked.Received.SingleMessage<ColorResponse>().Color.ShouldBe("red");
tracked.Received.SingleEnvelope<ColorResponse>()
.Destination.ShouldBe(new Uri("postgresql://response/"));

}
}

public record ColorRequest(string Color);
public record ColorResponse(string Color);

public static class ColorRequestHandler
{
public static async Task<ColorResponse> Handle(ColorRequest request)
{
await Task.Delay(Random.Shared.Next(0, 500).Milliseconds());
return new ColorResponse(request.Color);
}
}

public static class ColorResponseHandler
{
public static void Handle(ColorResponse response) => Debug.WriteLine("Got color response for " + response.Color);
}
2 changes: 1 addition & 1 deletion src/Persistence/Wolverine.Marten/MartenIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void Configure(WolverineOptions options)

var transport = options.Transports.GetOrCreate<PostgresqlTransport>();
transport.TransportSchemaName = TransportSchemaName;
transport.MessageStorageSchemaName = MessageStorageSchemaName;
transport.MessageStorageSchemaName = MessageStorageSchemaName ?? "public";
}

/// <summary>
Expand Down
Loading