NserviceBus 6 use RabbitMQTransport not working

1.6k Views Asked by At

We are using NSB v6.4.3, NServiceBus.RabbitMQ v4.4.1, RabbitMQ.Client v5.0.1. My Queues are created automatically, but I received this error and soon as I send a message to my queue.

"title": "Channel has been closed: AMQP close-reason, initiated by Peer, code=404, text=\"NOT_FOUND - no exchange 'SelfDriving.NServicebus' in vhost '/'\", classId=60, methodId=40, cause=.", "detail": " at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at NServiceBus.MutateOutgoingTransportMessageBehavior.d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at NServiceBus.SerializeMessageConnector.d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at NServiceBus.MutateOutgoingMessageBehavior.d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at NServiceBus.UnicastSendRouterConnector.d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at SelfDriving.Api.Controllers.BasicController.d__19.MoveNext() in C:\Source\innovate\self_driving_ideas.cs\SelfDriving.Api\Controllers\BasicController.cs:line 61\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at SelfDriving.Api.Controllers.FiltersController.d__3.MoveNext() in C:\Source\innovate\self_driving_ideas.cs\SelfDriving.Api\Controllers\FiltersController.cs:line 188\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at SelfDriving.Api.Controllers.FiltersController.d__2.MoveNext() in C:\Source\innovate\self_driving_ideas.cs\SelfDriving.Api\Controllers\FiltersController.cs:line 168\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()", "code": "System.Exception"

I don't have any problem when I'm using MsmqTransport This is my configuration code

    config = new EndpointConfiguration("SelfDriving.NServiceBus");
config.AssemblyScanner();
config.UsePersistence<InMemoryPersistence>();
config.LimitMessageProcessingConcurrencyTo(1);
var recoverability = config.Recoverability();
recoverability.Immediate( customizations: immediate => { immediate.NumberOfRetries(3);});
DefaultFactory defaultFactory = LogManager.Use<DefaultFactory>();
defaultFactory.Directory("c:\storage\Bus");
defaultFactory.Level(LogLevel.Error);
config.SendFailedMessagesTo("error");
config.AuditProcessedMessagesTo("audit", TimeSpan.FromDays(7));
var rabbitMQTransport = config.UseTransport<RabbitMQTransport>().Transactions(TransportTransactionMode.ReceiveOnly);
var rabbitMQRouting = rabbitMQTransport.Routing();
rabbitMQRouting.RouteToEndpoint(assembly: Assembly.GetAssembly(typeof (BasicMessage)),destination: "SelfDriving.NServiceBus");
config.SendOnly();
var endpointInstance = Endpoint.Start(config).GetAwaiter().GetResult();
2

There are 2 best solutions below

1
On

This issue happened because RabbitMQ is case sensitive and I was sending it to SelfDriving.NServicebus which is a wrong end point instead of SelfDriving.NServicebus This issue resolved as soon as I change the endpoint name

1
On

You are configuring your endpoint as SendOnly. That means there's no incoming queue. But you also configure routing to send all messages inside the assembly in which BasicMessage is located to this exact same endpoint.

That's causing the issue no exchange 'SelfDriving.NServicebus'

If you remove the SendOnly option it'll probably work.