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

[Host.Hybrid] SlimMessageBus.Host.ConfigurationMessageBusException: Could not find any bus that produces the message type #199

Closed
zarusz opened this issue Nov 25, 2023 · 0 comments · Fixed by #200

Comments

@zarusz
Copy link
Owner

zarusz commented Nov 25, 2023

Given a Hybrid Bus with an In-Memory bus as the child,
When publishing a domain event for the in-memory bus that has no consumer or handler registered,
We are getting the following exception raised by Hybrid Bus:

SlimMessageBus.Host.ConfigurationMessageBusException: Could not find any bus that produces the message type: <MessageType>

Sample:

// will raise the exception
await MessageBus.Current.Publish(new CustomerCreatedEvent(Id))

Configuration (shortened):

services.AddSlimMessageBus(mbb =>
{
    mbb
        .AddChildBus("Memory", builder =>
        {
            var namespaceNames = new[] { "DomainEventHandlers", "QueryHandlers", "CommandHandlers" };
            builder
                .WithProviderMemory()
                .AutoDeclareFrom(
                    typeof(CustomerCommandHandler).Assembly,
                    consumerTypeFilter: (consumerType) => Array.Exists(namespaceNames, x => consumerType.Namespace.Contains(x, StringComparison.InvariantCultureIgnoreCase)));
        })
        .AddChildBus("AzureSB", builder =>
        {
            builder
                // ...
                .WithProviderServiceBus(cfg => { });
        });
});

While the AutoDeclareFrom() did not find any handler/consumer that consumes the type CustomerCreatedEvent, the hybrid should still not raise an exception. At least we could have a configuration on the hybrid to not fail and perhaps just log a one-time WARN log.

@zarusz zarusz self-assigned this Nov 25, 2023
zarusz added a commit that referenced this issue Nov 25, 2023
…ould not find any bus that produces the message type #199

Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
zarusz added a commit that referenced this issue Nov 25, 2023
…ould not find any bus that produces the message type #199

Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
zarusz added a commit that referenced this issue Nov 25, 2023
…ould not find any bus that produces the message type #199

Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
zarusz added a commit that referenced this issue Nov 25, 2023
…ould not find any bus that produces the message type #199

Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
zarusz added a commit that referenced this issue Nov 25, 2023
…ould not find any bus that produces the message type #199

Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant