SzymonPobiega / NServiceBus.Router

Cross-transport, cross-site and possibly cross-cloud router component for NServiceBus
MIT License
5 stars 10 forks source link

Cannot use "RegisterPublisher" for SendOnly enpoints in Azure Service Bus #26

Open martinosk opened 4 years ago

martinosk commented 4 years ago

I'm trying to migrate some subscribers to RabbitMQ, while publishers are still on Azure Service Bus. This does not seem to work if the publisher is a SendOnly endpoint. Following exception is thrown: 2020-03-20 15:25:31.109 ERROR ThrottlingRawEndpointConfig1[[NServiceBus.RabbitMQTransport, NServiceBus.Transport.RabbitMQ, Version=5.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] Error processing a message. Continuing in throttled mode. Microsoft.Azure.ServiceBus.MessagingEntityNotFoundException: Put token failed. status-code: 404, status-description: The messaging entity 'sb://testnamespaceiaoao.servicebus.windows.net/legacy-publisher' could not be found. To know more visit https://aka.ms/sbResourceMgrExceptions. TrackingId:732270da-9516-4813-bc61-3f1cbaa626c1_G5, SystemTracker:seabookdev.servicebus.windows.net:legacy-publisher, Timestamp:2020-03-20T14:25:32. at Microsoft.Azure.ServiceBus.Core.MessageSender.OnSendAsync(IList1 messageList) at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func1 operation, TimeSpan operationTimeout) at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func1 operation, TimeSpan operationTimeout) at Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList1 messageList) at PostroutingTerminator.Terminate(PostroutingContext context) at NServiceBus.Router.ChainTerminator1.Invoke(T context, Func2 next) at NServiceBus.Router.TerminatorInvocationRule1.Invoke(T context, Func2 next) at NServiceBus.Router.Migrator.ShadowForwardSubscribeRule.Terminate(ForwardSubscribeContext context) at NServiceBus.Router.ChainTerminator1.Invoke(T context, Func2 next) at NServiceBus.Router.TerminatorInvocationRule1.Invoke(T context, Func2 next) at SubscribePreroutingTerminator.Terminate(SubscribePreroutingContext context) at NServiceBus.Router.ChainTerminator1.Invoke(T context, Func2 next) at NServiceBus.Router.TerminatorInvocationRule1.Invoke(T context, Func2 next) at PreroutingToSubscribePreroutingFork.Invoke(PreroutingContext context, Func2 next) at ThrottlingRawEndpointConfig`1.<>c__DisplayClass2_0.<b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at NServiceBus.Transport.RabbitMQ.MessagePump.Process(BasicDeliverEventArgs message)

SzymonPobiega commented 4 years ago

Hey

The exception you see means that there is no queue legacy-publisher publisher on the azure side. Not sure what is this message and why it is about to be sent to the publisher. Can you include your router configuration code and the Router.Connector configuration from your subscriber?

martinosk commented 4 years ago
            var routing = endpointConfig.EnableTransportMigration<AzureServiceBusTransport, RabbitMQTransport>(
                asb =>
                {
                    asb.ConnectionString(asbConnString);                    
                    asb.Transactions(TransportTransactionMode.ReceiveOnly);
                },
                rmq =>
                {
                    rmq.ConnectionString("UserName=guest;Password=guest;host=localhost;");
                    rmq.UseConventionalRoutingTopology();
                });

            routing.RegisterPublisher(typeof(DummyEvent), "maosk-legacy-publisher");
SzymonPobiega commented 4 years ago

Ah, that unfortunately won't work. The transport migration tool currently only works between transports that use message-driven pub/sub (MSMQ, SQL Server 4, ASQ) and transports that have native pub/sub support.

In your case you need to use the regular Router APIs and set up a router between ASB and RabbitMQ as a separate thing. You can still host it in the same process as one of you endpoints.

Take a look at this sample https://docs.particular.net/samples/router/mixed-transports/.