I am using Microservices deployed on Kubernetes built using asp.net core 2.2. Each microservice is subscribed to different azure service bus "Subscription". In application start up the service add subscription rules (filters) for events that it want to listen to.
Everything works fine and service process messages that it's subscribed to except when i kill the pod and Kubernetes bring back the replica and then service stops processing the messages and they keep on stacking in the queue. Regardless of how much i wait they are not processed even when i restart the pod.
My Startup.cs
public static IServiceCollection RegisterEventBus(this IServiceCollection services, IConfiguration configuration)
{
var subscriptionClientName = configuration["SubscriptionClientName"];
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
{
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
eventBusSubcriptionsManager, subscriptionClientName, iLifetimeScope);
});
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
services.AddTransient<PaymentProcessedIntegrationEventHandler>();
services.AddTransient<OrderStatusChangedIntegrationEventHandler>();
return services;
}
//Subscribe to Events
private void ConfigureEventBus(IApplicationBuilder app)
{
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
eventBus.Subscribe<PaymentProcessedIntegrationEvent, PaymentProcessedIntegrationEventHandler>();
eventBus.Subscribe<OrderStatusChangedIntegrationEvent, OrderStatusChangedIntegrationEventHandler>();
}
I copied official Azure Service bus class from eshopcontainers from github and using it in my project here.
Any help is highly appreciated !