-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempting to recreate the out of order publishing, but did "fix" the…
… execution tracking. Closes GH-468
- Loading branch information
1 parent
388bcd7
commit 76f40af
Showing
2 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...rts/RabbitMQ/Wolverine.RabbitMQ.Tests/Bugs/Bug_475_durable_outbox_sending_out_of_order.cs
This file contains 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,76 @@ | ||
using System.Diagnostics; | ||
using IntegrationTests; | ||
using Marten; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Oakton.Resources; | ||
using TestingSupport; | ||
using Wolverine.Marten; | ||
using Wolverine.Tracking; | ||
using Xunit; | ||
|
||
namespace Wolverine.RabbitMQ.Tests.Bugs; | ||
|
||
public class Bug_475_durable_outbox_sending_out_of_order | ||
{ | ||
[Fact] | ||
public async Task try_messages() | ||
{ | ||
var queueName = RabbitTesting.NextQueueName(); | ||
|
||
var tracker = new OrderTracker(); | ||
|
||
using var host = await Host.CreateDefaultBuilder() | ||
.UseWolverine(opts => | ||
{ | ||
opts.Services.AddSingleton(tracker); | ||
|
||
opts.Services.AddMarten(Servers.PostgresConnectionString) | ||
.IntegrateWithWolverine(); | ||
|
||
opts.UseRabbitMq().AutoProvision().AutoPurgeOnStartup(); | ||
|
||
opts.PublishAllMessages().ToRabbitQueue(queueName).SendInline(); | ||
opts.ListenToRabbitQueue(queueName).Sequential(); | ||
|
||
opts.Policies.UseDurableInboxOnAllListeners(); | ||
opts.Policies.UseDurableOutboxOnAllSendingEndpoints(); | ||
}).StartAsync(); | ||
|
||
await host.ResetResourceState(); | ||
|
||
Func<IMessageBus, Task> publishing = async bus => | ||
{ | ||
await bus.PublishAsync(new OrderedMessage(1)); | ||
await bus.PublishAsync(new OrderedMessage(2)); | ||
await bus.PublishAsync(new OrderedMessage(3)); | ||
await bus.PublishAsync(new OrderedMessage(4)); | ||
await bus.PublishAsync(new OrderedMessage(5)); | ||
await bus.PublishAsync(new OrderedMessage(6)); | ||
}; | ||
|
||
await host.TrackActivity().IncludeExternalTransports().ExecuteAndWaitAsync(publishing); | ||
|
||
tracker.Encountered.ShouldHaveTheSameElementsAs(1, 2,3 ,4,5,6); | ||
} | ||
} | ||
|
||
public static class OrderedMessageHandler | ||
{ | ||
public static void Handle(OrderedMessage message, OrderTracker tracker) | ||
{ | ||
tracker.Encountered.Add(message.Order); | ||
} | ||
} | ||
|
||
public record OrderedMessage(int Order); | ||
|
||
public class OrderTracker | ||
{ | ||
public OrderTracker() | ||
{ | ||
Debug.WriteLine("foo"); | ||
} | ||
|
||
public List<int> Encountered { get; } = new(); | ||
} |
This file contains 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