I am using NServiceBus along with AzureServiceBus transport layer in my .net application. The publisher in .net core web application and the subscriber is .net core console application. Now the issue is I am publishing event for web application and in Azure portal I can see message count increasing after every publish event in Subscribers "Orders" under "bundle-1" topics created as default topic by NServiceBus in Azure Service Bus. But topic's "Active message count" is 0. But my subscriber is doing nothing means it's not listening. What am I doing wrong? Here is the publisher configuration:
var endpointConfiguration = new EndpointConfiguration("Products");
endpointConfiguration.EnableCallbacks();
var instanceDiscriminator = "8e3af657-tt56-asd3-a75c-2fe8c4bcb635";
endpointConfiguration.MakeInstanceUniquelyAddressable(instanceDiscriminator);
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
transport.ConnectionString("connectionstring");
var routing = transport.Routing();
routing.RouteToEndpoint(
assembly: typeof(OrderPlacedEvent).Assembly,
destination: "Orders");
endpointInstance = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();
services.AddSingleton<IMessageSession>(endpointInstance);
and publishing code:
await _messageSession.Publish(new OrderPlacedEvent {OrderId = 1}).ConfigureAwait(false);
and subscriber's code:
Console.Title = "Orders";
IServiceCollection serviceProvider = new ServiceCollection();
serviceProvider = Configuration.ConfigureService(serviceProvider);
var endpointConfiguration = new EndpointConfiguration("Orders");
endpointConfiguration.SendFailedMessagesTo("error");
endpointConfiguration.UseSerialization<NewtonsoftSerializer>();
endpointConfiguration.AuditProcessedMessagesTo("audit");
endpointConfiguration.EnableInstallers();
endpointConfiguration.UseContainer<ServicesBuilder>(customizations =>
{
customizations.ExistingServices(serviceProvider);
});
endpointConfiguration.UsePersistence<InMemoryPersistence>();
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
transport.RuleNameShortener(n => n.Length > 50 ? MD5DeterministicNameBuilder.Build(n) : n);
transport.ConnectionString("connectionString");
var endpointInstance = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();
Console.WriteLine("Press Enter to exit.");
Console.ReadLine();
endpointInstance.Stop().GetAwaiter().GetResult();
and the event:
public class OrderPlacedEvent : IEvent {}
Now I have a debugger attached in my handler but it never gets hit. One more thing I also have some commands and the commands are working fine. The message counter of Queue gets updated when ever I send any command and subscriber always listen to commands. One last thing to mention I am using free trial of Azure portal but I think that wouldn't be an issue because commands are working fine. Any help?