0

I have two console applications. At start, both configure an endpoint like this:

public static async Task<IEndpointInstance> CreateEndpoint()
{
    var endpointConfiguration = new EndpointConfiguration("ep");
    endpointConfiguration.DisableFeature<TimeoutManager>();
    endpointConfiguration.EnableInstallers();

    var transport = endpointConfiguration.UseTransport<SqlServerTransport>();
    transport.ConnectionString(ConnectionString);
    transport.NativeDelayedDelivery().DisableTimeoutManagerCompatibility();

    var routing = transport.Routing();
    routing.RouteToEndpoint(typeof(DoSomething), "ep");

    return await Endpoint.Start(endpointConfiguration);
}

So both applications access the same SQL Server Database and have the same Main method.

static async Task Main(string[] args)
{
    var endpointInstance = await EndpointHelper.CreateEndpoint();

    while (true)
    {
        var key = Console.ReadKey();

        switch (key.Key)
        {
            case ConsoleKey.P:
                var command = new MyCommand { SomeProperty = "Test" };
                await endpointInstance.Publish(command);
                break;
        }
    }
}

Both console applications have an event handler declared. The problem is that when an event happens, only one of the two console applications gets notified. Sometimes the first, sometimes the second.

Why? What configuration am I missing? I want every console application to react when an event happens.

user2877820
  • 287
  • 4
  • 19

1 Answers1

0

If both endpoints have the same endpoint name (and so the same queue) only one will receive the event as they are competing consumers, they are logically the same endpoint... try and define one of them with a different endpoint name so they have a separate queue.

var endpointConfiguration = new EndpointConfiguration("ep");

so the other endpoint will have var endpointConfiguration = new EndpointConfiguration("ep1");

Sean Farmar
  • 2,254
  • 13
  • 10