Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArtemisNetClient.Testing doesn't support multiple consumer on the same address #450

Closed
Havret opened this issue Aug 6, 2023 · 0 comments · Fixed by #451 or #462
Closed

ArtemisNetClient.Testing doesn't support multiple consumer on the same address #450

Havret opened this issue Aug 6, 2023 · 0 comments · Fixed by #451 or #462
Labels
bug Something isn't working

Comments

@Havret
Copy link
Owner

Havret commented Aug 6, 2023

Describe the bug

Attempting to attach multiple consumers with identical addresses results in an exception from the ArtemisNetClient.Testing.

Exception Details:

ActiveMQ.Artemis.Client.Exceptions.CreateConsumerException: Link 'testQueue' has been attached already.

ActiveMQ.Artemis.Client.Exceptions.CreateConsumerException
Link 'testQueue' has been attached already.
   at ActiveMQ.Artemis.Client.Builders.ConsumerBuilder.CreateAsync(ConsumerConfiguration configuration, CancellationToken cancellationToken) in /Users/havret/git/dotnet-activemq-artemis-client/src/ArtemisNetClient/Builders/ConsumerBuilder.cs:line 44
   at ActiveMQ.Artemis.Client.Connection.CreateConsumerAsync(ConsumerConfiguration configuration, CancellationToken cancellationToken) in /Users/havret/git/dotnet-activemq-artemis-client/src/ArtemisNetClient/Connection.cs:line 65
   at ActiveMQ.Artemis.Client.AutoRecovering.AutoRecoveringConsumer.RecoverAsync(IConnection connection, CancellationToken cancellationToken) in /Users/havret/git/dotnet-activemq-artemis-client/src/ArtemisNetClient/AutoRecovering/AutoRecoveringConsumer.cs:line 118
   at ActiveMQ.Artemis.Client.AutoRecovering.AutoRecoveringConnection.PrepareRecoverable(IRecoverable recoverable, CancellationToken cancellationToken) in /Users/havret/git/dotnet-activemq-artemis-client/src/ArtemisNetClient/AutoRecovering/AutoRecoveringConnection.cs:line 234
   at ActiveMQ.Artemis.Client.AutoRecovering.AutoRecoveringConnection.CreateConsumerAsync(ConsumerConfiguration configuration, CancellationToken cancellationToken) in /Users/havret/git/dotnet-activemq-artemis-client/src/ArtemisNetClient/AutoRecovering/AutoRecoveringConnection.cs:line 203
   at ActiveMQ.Artemis.Client.Testing.UnitTests.SendMessageSpec.Should_send_message_to_multiple_shared_consumers() in /Users/havret/git/dotnet-activemq-artemis-client/test/ArtemisNetClient.Testing.UnitTests/SendMessageSpec.cs:line 91
   at ActiveMQ.Artemis.Client.Testing.UnitTests.SendMessageSpec.Should_send_message_to_multiple_shared_consumers() in /Users/havret/git/dotnet-activemq-artemis-client/test/ArtemisNetClient.Testing.UnitTests/SendMessageSpec.cs:line 102
   at ActiveMQ.Artemis.Client.Testing.UnitTests.SendMessageSpec.Should_send_message_to_multiple_shared_consumers() in /Users/havret/git/dotnet-activemq-artemis-client/test/ArtemisNetClient.Testing.UnitTests/SendMessageSpec.cs:line 102
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
--- End of stack trace from previous location ---
   at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90

Expected behavior

The library should allow multiple consumers to be attached to the TestKit using the same address name without any issues.

Environment:

  • OS: macOS Ventura 13.4.1 (22F82)
  • Version: 2.12.0
  • Broker: n/a

Additional context

Failing test case:

[Fact]
public async Task Should_send_message_to_multiple_shared_consumers()
{
    var endpoint = EndpointUtil.GetUniqueEndpoint();
    using var testKit = new TestKit(endpoint);

    var connectionFactory = new ConnectionFactory();
    await using var connection = await connectionFactory.CreateAsync(endpoint);
    
    var testAddress = "test_address";
    var testQueue = "testQueue";
    await using var consumer1 = await connection.CreateConsumerAsync(new ConsumerConfiguration
    {
        Address = testAddress,
        Queue = testQueue,
        Shared = true
    });
    await using var consumer2 = await connection.CreateConsumerAsync(new ConsumerConfiguration
    {
        Address = testAddress,
        Queue = testQueue,
        Shared = true
    });

    await testKit.SendMessageAsync(testAddress, new Message("foo1"));
    await testKit.SendMessageAsync(testAddress, new Message("foo2"));

    Assert.Equal("foo1", (await consumer1.ReceiveAsync()).GetBody<string>());
    Assert.Equal("foo2", (await consumer2.ReceiveAsync()).GetBody<string>());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant