Hi, I have two Endpoints running in a single Process. Both monitor different SQS Queues (Say Q1 and Q2)
One message handler publishes an event at the end of the handler method. This message is sent to Q1.
The subscribers send their subscribe messages to Q1.
However the Endpoint that monitors Q2 is processing the subscription messages. It is also the Endpoint that is processing messages SENT to Q1.
I am using SQS transport. I am also using Autofac containers where I send in my .net core services collection and use
endpointConfiguration.UseContainer(customizations: customizations =>
{
customizations.ExistingLifetimeScope(_externalContainer);
});
Where the externalContainer is created using all services registered in my aspnet api application via an IServiceCollection extension.
public static IServiceCollection AddNSB(this IServiceCollection services, string hostName)
{
//Build our container with all services required by the Handlers
services.AddSingleton<IContainer>(_ =>
{
var builder = new ContainerBuilder();
builder.Populate(services);
return builder.Build();
});
This has been done so that the message handler can access services that are also used by the application.
I assume that something is getting registered in the container and the second endpoint is over-riding a service registered by the first Endpoint. This can be seen if I reverse the start sequence so that Q2 starts before Q1.
If I don’t use the services collection but instead explicitly register the services used by the message handlers then it works. However I would like to be able to use the same service collection provided by aspnet core.
Do you have any suggestions?