diff --git a/src/Host.Plugin.Properties.xml b/src/Host.Plugin.Properties.xml index 1228b730..fc8c3714 100644 --- a/src/Host.Plugin.Properties.xml +++ b/src/Host.Plugin.Properties.xml @@ -4,7 +4,7 @@ - 3.0.0-rc6 + 3.0.0-rc11 \ No newline at end of file diff --git a/src/SlimMessageBus.Host.Configuration/Builders/ConsumerBuilder.cs b/src/SlimMessageBus.Host.Configuration/Builders/ConsumerBuilder.cs index 219d9eda..48589242 100644 --- a/src/SlimMessageBus.Host.Configuration/Builders/ConsumerBuilder.cs +++ b/src/SlimMessageBus.Host.Configuration/Builders/ConsumerBuilder.cs @@ -8,14 +8,24 @@ public ConsumerBuilder(MessageBusSettings settings, Type messageType = null) ConsumerSettings.ConsumerMode = ConsumerMode.Consumer; } - public ConsumerBuilder Path(string path, Action> pathConfig = null) + public ConsumerBuilder Path(string path) { ConsumerSettings.Path = path; + return this; + } + + public ConsumerBuilder Path(string path, Action> pathConfig) + { + Path(path); pathConfig?.Invoke(this); return this; } - public ConsumerBuilder Topic(string topic, Action> topicConfig = null) => Path(topic, topicConfig); + public ConsumerBuilder Topic(string topic) + => Path(topic); + + public ConsumerBuilder Topic(string topic, Action> topicConfig) + => Path(topic, topicConfig); private static Task DefaultConsumerOnMethod(object consumer, object message, IConsumerContext consumerContext, CancellationToken cancellationToken) => ((IConsumer)consumer).OnHandle((T)message, cancellationToken); diff --git a/src/SlimMessageBus.Host.Configuration/Builders/HandlerBuilder.cs b/src/SlimMessageBus.Host.Configuration/Builders/HandlerBuilder.cs index 0cb8d5b6..d7573f45 100644 --- a/src/SlimMessageBus.Host.Configuration/Builders/HandlerBuilder.cs +++ b/src/SlimMessageBus.Host.Configuration/Builders/HandlerBuilder.cs @@ -14,6 +14,23 @@ protected AbstractHandlerBuilder(MessageBusSettings settings, Type messageType, } protected THandlerBuilder TypedThis => (THandlerBuilder)this; + + /// + /// Configure topic name (or queue name) that incoming requests () are expected on. + /// + /// Topic name + /// + public THandlerBuilder Path(string path) + { + var consumerSettingsExist = Settings.Consumers.Any(x => x.Path == path && x.ConsumerMode == ConsumerMode.RequestResponse && x != ConsumerSettings); + if (consumerSettingsExist) + { + throw new ConfigurationMessageBusException($"Attempted to configure request handler for path '{path}' when one was already configured. There can only be one request handler for a given path."); + } + + ConsumerSettings.Path = path; + return TypedThis; + } /// /// Configure topic name (or queue name) that incoming requests () are expected on. @@ -21,26 +38,29 @@ protected AbstractHandlerBuilder(MessageBusSettings settings, Type messageType, /// Topic name /// /// - public THandlerBuilder Path(string path, Action pathConfig = null) - { - var consumerSettingsExist = Settings.Consumers.Any(x => x.Path == path && x.ConsumerMode == ConsumerMode.RequestResponse && x != ConsumerSettings); - if (consumerSettingsExist) - { - throw new ConfigurationMessageBusException($"Attempted to configure request handler for path '{path}' when one was already configured. There can only be one request handler for a given path (topic/queue)"); - } - - ConsumerSettings.Path = path; + public THandlerBuilder Path(string path, Action pathConfig) + { + Path(path); pathConfig?.Invoke(TypedThis); return TypedThis; } + /// + /// Configure topic name (or queue name) that incoming requests () are expected on. + /// + /// Topic name + /// + public THandlerBuilder Topic(string topic) + => Path(topic); + /// /// Configure topic name (or queue name) that incoming requests () are expected on. /// /// Topic name /// /// - public THandlerBuilder Topic(string topic, Action topicConfig = null) => Path(topic, topicConfig); + public THandlerBuilder Topic(string topic, Action topicConfig) + => Path(topic, topicConfig); public THandlerBuilder Instances(int numberOfInstances) { diff --git a/src/SlimMessageBus.Host.Configuration/SlimMessageBus.Host.Configuration.csproj b/src/SlimMessageBus.Host.Configuration/SlimMessageBus.Host.Configuration.csproj index 210e2384..a1b9b632 100644 --- a/src/SlimMessageBus.Host.Configuration/SlimMessageBus.Host.Configuration.csproj +++ b/src/SlimMessageBus.Host.Configuration/SlimMessageBus.Host.Configuration.csproj @@ -6,7 +6,7 @@ Core configuration interfaces of SlimMessageBus SlimMessageBus SlimMessageBus.Host - 3.0.0-rc6 + 3.0.0-rc11 diff --git a/src/SlimMessageBus.Host.Interceptor/SlimMessageBus.Host.Interceptor.csproj b/src/SlimMessageBus.Host.Interceptor/SlimMessageBus.Host.Interceptor.csproj index d866a6c8..0bd8e2de 100644 --- a/src/SlimMessageBus.Host.Interceptor/SlimMessageBus.Host.Interceptor.csproj +++ b/src/SlimMessageBus.Host.Interceptor/SlimMessageBus.Host.Interceptor.csproj @@ -3,7 +3,7 @@ - 3.0.0-rc6 + 3.0.0-rc11 Core interceptor interfaces of SlimMessageBus SlimMessageBus diff --git a/src/SlimMessageBus.Host.Serialization/SlimMessageBus.Host.Serialization.csproj b/src/SlimMessageBus.Host.Serialization/SlimMessageBus.Host.Serialization.csproj index 076a8825..43251dd3 100644 --- a/src/SlimMessageBus.Host.Serialization/SlimMessageBus.Host.Serialization.csproj +++ b/src/SlimMessageBus.Host.Serialization/SlimMessageBus.Host.Serialization.csproj @@ -3,7 +3,7 @@ - 3.0.0-rc6 + 3.0.0-rc11 Core serialization interfaces of SlimMessageBus SlimMessageBus diff --git a/src/SlimMessageBus/SlimMessageBus.csproj b/src/SlimMessageBus/SlimMessageBus.csproj index 7715b625..37c72979 100644 --- a/src/SlimMessageBus/SlimMessageBus.csproj +++ b/src/SlimMessageBus/SlimMessageBus.csproj @@ -3,7 +3,7 @@ - 3.0.0-rc6 + 3.0.0-rc11 This library provides a lightweight, easy-to-use message bus interface for .NET, offering a simplified facade for working with messaging brokers. It supports multiple transport providers for popular messaging systems, as well as in-memory (in-process) messaging for efficient local communication. diff --git a/src/Tests/SlimMessageBus.Host.Configuration.Test/HandlerBuilderTest.cs b/src/Tests/SlimMessageBus.Host.Configuration.Test/HandlerBuilderTest.cs index bbb0fbfb..82e95fed 100644 --- a/src/Tests/SlimMessageBus.Host.Configuration.Test/HandlerBuilderTest.cs +++ b/src/Tests/SlimMessageBus.Host.Configuration.Test/HandlerBuilderTest.cs @@ -70,7 +70,7 @@ public void When_PathSet_Given_ThePathWasUsedBeforeOnAnotherHandler_Then_Excepti // assert act.Should() .Throw() - .WithMessage($"Attempted to configure request handler for path '*' when one was already configured. There can only be one request handler for a given path (topic/queue)"); + .WithMessage($"Attempted to configure request handler for path '*' when one was already configured. There can only be one request handler for a given path."); } [Theory] diff --git a/src/Tests/SlimMessageBus.Host.Outbox.DbContext.Test/OutboxTests.cs b/src/Tests/SlimMessageBus.Host.Outbox.DbContext.Test/OutboxTests.cs index 4f7fe49e..ca7c45f3 100644 --- a/src/Tests/SlimMessageBus.Host.Outbox.DbContext.Test/OutboxTests.cs +++ b/src/Tests/SlimMessageBus.Host.Outbox.DbContext.Test/OutboxTests.cs @@ -310,7 +310,7 @@ public record GenerateCustomerIdCommand(string Firstname, string Lastname) : IRe public class GenerateCustomerIdCommandHandler : IRequestHandler { - public async Task OnHandle(GenerateCustomerIdCommand request, CancellationToken cancellationToken) + public Task OnHandle(GenerateCustomerIdCommand request, CancellationToken cancellationToken) { // Note: This handler will be already wrapped in a transaction: see Program.cs and .UseTransactionScope() / .UseSqlTransaction()