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

Addressing some routing logic bugs in the fluent interface. Closes GH… #1104

Merged
merged 1 commit into from
Oct 27, 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
@@ -1,6 +1,8 @@
using System.Diagnostics;
using JasperFx.Core.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Module2;
using Wolverine.ComplianceTests;
using Wolverine.Attributes;
using Wolverine.Configuration;
Expand All @@ -13,7 +15,7 @@

namespace CoreTests.Runtime.Routing;

public class routing_precedence
public class routing_rules
{
[Fact]
public async Task local_routing_is_applied_automatically()
Expand Down Expand Up @@ -206,6 +208,25 @@ public async Task use_no_handler_if_no_handler_and_no_subscriber()
collection.FindInvoker(typeof(RedMessage))
.ShouldBeOfType<NoHandlerExecutor>();
}

// This one is for https://github.com/JasperFx/wolverine/issues/1099
[Fact]
public async Task route_with_fluent_interface()
{
var port = PortFinder.GetAvailablePort();
using var host = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
//opts.Discovery.IncludeAssembly(typeof(Module2Message1).Assembly);
opts.Publish().MessagesFromAssembly(typeof(Module2Message1).Assembly).ToPort(port);

}).StartAsync();

var bus = host.MessageBus();
var envelopes = bus.PreviewSubscriptions(new Module2Message1());

envelopes.Single().Destination.ShouldBe(new Uri("tcp://localhost:" + port));
}
}

public class ColorsMessageHandler
Expand Down
3 changes: 3 additions & 0 deletions src/Wolverine/Configuration/PublishingExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public PublishingExpression Message(Type type)
/// <returns></returns>
public PublishingExpression MessagesFromNamespace(string @namespace)
{
AutoAddSubscriptions = true;

_subscriptions.Add(new Subscription
{
Match = @namespace,
Expand Down Expand Up @@ -144,6 +146,7 @@ public PublishingExpression MessagesFromNamespaceContaining<T>()
public PublishingExpression MessagesFromAssembly(Assembly assembly)
{
_subscriptions.Add(new Subscription(assembly));
AutoAddSubscriptions = true;
return this;
}

Expand Down
Loading