-
-
Notifications
You must be signed in to change notification settings - Fork 96
Fix RabbitMQ queue binding and Gateway GetOriginalStream #498
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
Merged
alexeyzimarev
merged 2 commits into
dev
from
fix/rabbitmq-queue-bind-and-gateway-stream
Feb 27, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/Gateway/test/Eventuous.Tests.Gateway/GatewayMetaTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| using Eventuous.Gateway; | ||
| using Eventuous.Producers; | ||
|
|
||
| namespace Eventuous.Tests.Gateway; | ||
|
|
||
| public class GatewayMetaTests { | ||
| [Test] | ||
| public async Task GetOriginalStream_ReturnsStreamName() { | ||
| var streamName = new StreamName("Test-123"); | ||
|
|
||
| var headers = new Metadata(new Dictionary<string, object?> { | ||
| [GatewayContextItems.OriginalStream] = streamName | ||
| }); | ||
|
|
||
| var message = new ProducedMessage("test", null, headers); | ||
|
|
||
| var result = message.GetOriginalStream(); | ||
|
|
||
| await Assert.That(result).IsNotNull(); | ||
| await Assert.That(result!.Value).IsEqualTo(streamName); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task GetOriginalMessageId_ReturnsMessageId() { | ||
| var messageId = Guid.NewGuid().ToString(); | ||
|
|
||
| var headers = new Metadata(new Dictionary<string, object?> { | ||
| [GatewayContextItems.OriginalMessageId] = messageId | ||
| }); | ||
|
|
||
| var message = new ProducedMessage("test", null, headers); | ||
|
|
||
| await Assert.That(message.GetOriginalMessageId()).IsEqualTo(messageId); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task GetOriginalMessageType_ReturnsMessageType() { | ||
| var headers = new Metadata(new Dictionary<string, object?> { | ||
| [GatewayContextItems.OriginalMessageType] = "test-event" | ||
| }); | ||
|
|
||
| var message = new ProducedMessage("test", null, headers); | ||
|
|
||
| await Assert.That(message.GetOriginalMessageType()).IsEqualTo("test-event"); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task GetOriginalStreamPosition_ReturnsPosition() { | ||
| var headers = new Metadata(new Dictionary<string, object?> { | ||
| [GatewayContextItems.OriginalStreamPosition] = 42UL | ||
| }); | ||
|
|
||
| var message = new ProducedMessage("test", null, headers); | ||
|
|
||
| await Assert.That(message.GetOriginalStreamPosition()).IsEqualTo(42UL); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task GetOriginalStream_WithNullHeaders_ReturnsNull() { | ||
| var message = new ProducedMessage("test", null); | ||
|
|
||
| await Assert.That(message.GetOriginalStream()).IsNull(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/RabbitMq/test/Eventuous.Tests.RabbitMq/CustomQueueSubscriptionSpec.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| using Eventuous.Producers; | ||
| using Eventuous.RabbitMq.Producers; | ||
| using Eventuous.RabbitMq.Subscriptions; | ||
| using Eventuous.Subscriptions.Filters; | ||
| using Eventuous.TestHelpers.TUnit; | ||
| using Eventuous.TestHelpers.TUnit.Logging; | ||
| using Eventuous.Tests.Subscriptions.Base; | ||
|
|
||
| namespace Eventuous.Tests.RabbitMq; | ||
|
|
||
| [ClassDataSource<RabbitMqFixture>] | ||
| public class CustomQueueSubscriptionSpec { | ||
| static CustomQueueSubscriptionSpec() => TypeMap.Instance.RegisterKnownEventTypes(typeof(TestEvent).Assembly); | ||
|
|
||
| RabbitMqProducer _producer = null!; | ||
| TestEventHandler _handler = null!; | ||
| #pragma warning disable TUnit0023 | ||
| RabbitMqSubscription _subscription = null!; | ||
| TestEventListener _es = null!; | ||
| #pragma warning restore TUnit0023 | ||
| readonly StreamName _exchange; | ||
| readonly ILogger<CustomQueueSubscriptionSpec> _log; | ||
| readonly ILoggerFactory _loggerFactory; | ||
| readonly RabbitMqFixture _fixture; | ||
|
|
||
| public CustomQueueSubscriptionSpec(RabbitMqFixture fixture) { | ||
| _fixture = fixture; | ||
| _exchange = new(Guid.NewGuid().ToString()); | ||
| _loggerFactory = LoggingExtensions.GetLoggerFactory(); | ||
| _log = _loggerFactory.CreateLogger<CustomQueueSubscriptionSpec>(); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task SubscribeWithCustomQueueName(CancellationToken cancellationToken) { | ||
| var testEvent = TestEvent.Create(); | ||
| await _producer.Produce(_exchange, testEvent, new(), cancellationToken: cancellationToken); | ||
| await _handler.AssertThat().Timebox(10.Seconds()).Any().Match(x => x as TestEvent == testEvent).Validate(cancellationToken); | ||
| } | ||
|
|
||
| [Before(Test)] | ||
| public async ValueTask InitializeAsync() { | ||
| _es = new(); | ||
| _handler = new(); | ||
| _producer = new(_fixture.ConnectionFactory); | ||
|
|
||
| var subscriptionId = Guid.NewGuid().ToString(); | ||
| var customQueue = Guid.NewGuid().ToString(); | ||
|
|
||
| _subscription = new( | ||
| _fixture.ConnectionFactory, | ||
| new RabbitMqSubscriptionOptions { | ||
| ConcurrencyLimit = 10, | ||
| SubscriptionId = subscriptionId, | ||
| Exchange = _exchange, | ||
| ThrowOnError = true, | ||
| QueueOptions = new RabbitMqSubscriptionOptions.RabbitMqQueueOptions { Queue = customQueue } | ||
| }, | ||
| new ConsumePipe().AddDefaultConsumer(_handler), | ||
| _loggerFactory | ||
| ); | ||
| await _subscription.SubscribeWithLog(_log); | ||
| await _producer.StartAsync(); | ||
| } | ||
|
|
||
| [After(Test)] | ||
| public async ValueTask DisposeAsync() { | ||
| await _producer.StopAsync(); | ||
| await _subscription.UnsubscribeWithLog(_log); | ||
| _es.Dispose(); | ||
| await _subscription.DisposeAsync(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Public api return-type break
🐞 Bug⛯ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools