-
Notifications
You must be signed in to change notification settings - Fork 7
Separate outbox records by endpoint name to enable properly sharing the same collection between endpoints #799
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
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8348554
Add an acceptance test
danielmarbach 9603a74
Simple straight forward implementation to make the test pass
danielmarbach 3137ab7
Use an equality predicate with fallback
danielmarbach 1f447cb
Upconvert old legacy entries
danielmarbach eb9e8c0
Remove todo for now
danielmarbach 6445a6f
Move time to keep duplication data to outbox settings
danielmarbach e7d5675
Making sure the outbox class mappings are always present before the c…
danielmarbach 52a4036
Proper namespaces and wire up new configuration
danielmarbach 1aa7a3a
Remove unneeded Mongo prefix
danielmarbach d93a971
Remove unneeded check
danielmarbach f917653
Introduce read fallback and run persistence tests without
danielmarbach 3e1e6b6
Fix default class map indicator
danielmarbach 1cfe791
Forgot to approve the rename
danielmarbach 6aee372
Bring back the default of seven days for TTL
danielmarbach 78ccdac
Make sure the processor endpoint is taken into account
danielmarbach 5baeae5
Disable outbox installation when processor endpoint is set
danielmarbach 9afcacb
Suppress null warning
danielmarbach 00d6270
Make outbox settings extensions still fluent since others are too
danielmarbach b98b545
Inline the hierarchy since we really only have these outbox tests and…
danielmarbach 392684c
Some minor formattingˆ
danielmarbach 34b3e64
Additional test
danielmarbach 88a5956
Use explicit fallback sacrificing network latency for a more safe by …
danielmarbach 4b1a306
Remove TODO for now since we can deal with this elsewhere
danielmarbach ec1258f
Extract filtering
danielmarbach efaef8c
Comment
danielmarbach 379c950
Comment
danielmarbach 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
101 changes: 101 additions & 0 deletions
101
src/NServiceBus.Storage.MongoDB.AcceptanceTests/When_subscribers_handles_the_same_event.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,101 @@ | ||
| namespace NServiceBus.AcceptanceTests.Outbox; | ||
|
|
||
| using System; | ||
| using System.Threading.Tasks; | ||
| using AcceptanceTesting; | ||
| using AcceptanceTesting.Customization; | ||
| using AcceptanceTests; | ||
| using EndpointTemplates; | ||
| using NUnit.Framework; | ||
|
|
||
| public class When_subscribers_handles_the_same_event : NServiceBusAcceptanceTest | ||
| { | ||
| [Test] | ||
| public async Task Should_be_processed_by_all_subscribers() | ||
| { | ||
| var context = await Scenario.Define<Context>() | ||
| .WithEndpoint<Publisher>(b => | ||
| b.When(c => c.Subscriber1Subscribed && c.Subscriber2Subscribed, session => session.Publish(new MyEvent())) | ||
| ) | ||
| .WithEndpoint<Subscriber1>() | ||
| .WithEndpoint<Subscriber2>() | ||
| .Done(c => c.Subscriber1GotTheEvent && c.Subscriber2GotTheEvent) | ||
| .Run(TimeSpan.FromSeconds(10)); | ||
|
|
||
| Assert.Multiple(() => | ||
| { | ||
| Assert.That(context.Subscriber1GotTheEvent, Is.True); | ||
| Assert.That(context.Subscriber2GotTheEvent, Is.True); | ||
| }); | ||
| } | ||
|
|
||
| public class Context : ScenarioContext | ||
| { | ||
| public bool Subscriber1Subscribed { get; set; } | ||
| public bool Subscriber2Subscribed { get; set; } | ||
|
|
||
| public bool Subscriber1GotTheEvent { get; set; } | ||
| public bool Subscriber2GotTheEvent { get; set; } | ||
| } | ||
|
|
||
| public class Publisher : EndpointConfigurationBuilder | ||
| { | ||
| public Publisher() => EndpointSetup<DefaultPublisher>(c => | ||
| { | ||
| c.OnEndpointSubscribed<Context>((s, context) => | ||
| { | ||
| var subscriber1 = Conventions.EndpointNamingConvention(typeof(Subscriber1)); | ||
| if (s.SubscriberEndpoint.Contains(subscriber1)) | ||
| { | ||
| context.Subscriber1Subscribed = true; | ||
| } | ||
|
|
||
| var subscriber2 = Conventions.EndpointNamingConvention(typeof(Subscriber2)); | ||
| if (s.SubscriberEndpoint.Contains(subscriber2)) | ||
| { | ||
| context.Subscriber2Subscribed = true; | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| public class Subscriber1 : EndpointConfigurationBuilder | ||
| { | ||
| public Subscriber1() => | ||
| EndpointSetup<DefaultServer>(c => | ||
| { | ||
| c.ConfigureTransport().TransportTransactionMode = TransportTransactionMode.ReceiveOnly; | ||
| c.EnableOutbox(); | ||
| }, metadata => metadata.RegisterPublisherFor<MyEvent>(typeof(Publisher))); | ||
|
|
||
| public class MyHandler(Context testContext) : IHandleMessages<MyEvent> | ||
| { | ||
| public Task Handle(MyEvent message, IMessageHandlerContext context) | ||
| { | ||
| testContext.Subscriber1GotTheEvent = true; | ||
| return Task.CompletedTask; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public class Subscriber2 : EndpointConfigurationBuilder | ||
| { | ||
| public Subscriber2() => | ||
| EndpointSetup<DefaultServer>(c => | ||
| { | ||
| c.ConfigureTransport().TransportTransactionMode = TransportTransactionMode.ReceiveOnly; | ||
| c.EnableOutbox(); | ||
| }, metadata => metadata.RegisterPublisherFor<MyEvent>(typeof(Publisher))); | ||
|
|
||
| public class MyHandler(Context testContext) : IHandleMessages<MyEvent> | ||
| { | ||
| public Task Handle(MyEvent messageThatIsEnlisted, IMessageHandlerContext context) | ||
| { | ||
| testContext.Subscriber2GotTheEvent = true; | ||
| return Task.CompletedTask; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public class MyEvent : IEvent; | ||
| } | ||
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
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
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
22 changes: 0 additions & 22 deletions
22
src/NServiceBus.Storage.MongoDB.Tests/Outbox/OutboxPersisterTests.cs
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
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.
@andreasohlund I took over the test you wrote. I think this should be moved into Core ideally. Thoughts?
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.
Agreed