-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New IConfigureLocalQueue mechanism for fine tuning local queues even …
…when using sticky handler assignments. Closes GH-1213
- Loading branch information
1 parent
d55890e
commit 5289de1
Showing
9 changed files
with
271 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
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
134 changes: 134 additions & 0 deletions
134
src/Testing/CoreTests/Acceptance/configuring_local_queues.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,134 @@ | ||
using JasperFx.Core.Reflection; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Wolverine.Attributes; | ||
using Wolverine.Configuration; | ||
using Wolverine.Tracking; | ||
using Wolverine.Transports.Local; | ||
using Xunit; | ||
|
||
namespace CoreTests.Acceptance; | ||
|
||
public class configuring_local_queues : IntegrationContext | ||
{ | ||
public configuring_local_queues(DefaultApp @default) : base(@default) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void apply_to_normal_non_sticky_default_routed_handler() | ||
{ | ||
var runtime = Host.GetRuntime(); | ||
runtime.Endpoints.EndpointByName("Frank") | ||
.ShouldBeOfType<LocalQueue>().Uri.ShouldBe(new Uri("local://coretests.acceptance.simplemessage/")); | ||
} | ||
|
||
[Fact] | ||
public void apply_to_sticky_handlers() | ||
{ | ||
var runtime = Host.GetRuntime(); | ||
runtime.Endpoints.EndpointByName("blue") | ||
.ShouldBeOfType<LocalQueue>().ExecutionOptions.MaxDegreeOfParallelism.ShouldBe(1); | ||
|
||
runtime.Endpoints.EndpointByName("green") | ||
.ShouldBeOfType<LocalQueue>().ExecutionOptions.MaxDegreeOfParallelism.ShouldBe(1000); | ||
} | ||
|
||
[Fact] | ||
public async Task use_with_separated_mode() | ||
{ | ||
using var host = await new HostBuilder().UseWolverine(opts => | ||
{ | ||
opts.MultipleHandlerBehavior = MultipleHandlerBehavior.Separated; | ||
}).StartAsync(); | ||
|
||
var runtime = host.GetRuntime(); | ||
runtime.Endpoints.EndpointByName(typeof(MultipleMessage1Handler).FullNameInCode().ToLowerInvariant()) | ||
.ShouldBeOfType<LocalQueue>().ExecutionOptions.MaxDegreeOfParallelism.ShouldBe(1); | ||
|
||
runtime.Endpoints.EndpointByName(typeof(MultipleMessage2Handler).FullNameInCode().ToLowerInvariant()) | ||
.ShouldBeOfType<LocalQueue>().ExecutionOptions.MaxDegreeOfParallelism.ShouldBe(1000); | ||
} | ||
} | ||
|
||
public record SimpleMessage; | ||
|
||
public class SimpleMessageHandler : IConfigureLocalQueue | ||
{ | ||
public static void Configure(LocalQueueConfiguration configuration) | ||
{ | ||
// Just got to do something to prove out the configuration | ||
configuration.Named("Frank"); | ||
} | ||
|
||
public static void Handle(SimpleMessage message) | ||
{ | ||
|
||
} | ||
} | ||
|
||
public record StuckMessage; | ||
|
||
[StickyHandler("blue")] | ||
public class BlueStuckMessageHandler : IConfigureLocalQueue | ||
{ | ||
public static void Configure(LocalQueueConfiguration configuration) | ||
{ | ||
configuration.Sequential(); | ||
} | ||
|
||
public static void Handle(StuckMessage message) | ||
{ | ||
|
||
} | ||
} | ||
|
||
[StickyHandler("green")] | ||
public class GreenStuckMessageHandler : IConfigureLocalQueue | ||
{ | ||
public static void Configure(LocalQueueConfiguration configuration) | ||
{ | ||
configuration.MaximumParallelMessages(1000); | ||
} | ||
|
||
public static void Handle(StuckMessage message) | ||
{ | ||
|
||
} | ||
} | ||
|
||
public record MultipleMessage; | ||
|
||
#region sample_using_IConfigureLocalQueue | ||
|
||
public class MultipleMessage1Handler : IConfigureLocalQueue | ||
{ | ||
public static void Handle(MultipleMessage message) | ||
{ | ||
|
||
} | ||
|
||
// This method is configuring the local queue that executes this | ||
// handler to be strictly ordered | ||
public static void Configure(LocalQueueConfiguration configuration) | ||
{ | ||
configuration.Sequential(); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
public class MultipleMessage2Handler : IConfigureLocalQueue | ||
{ | ||
public static void Handle(MultipleMessage message) | ||
{ | ||
|
||
} | ||
|
||
public static void Configure(LocalQueueConfiguration configuration) | ||
{ | ||
configuration.MaximumParallelMessages(1000); | ||
} | ||
} | ||
|
||
|
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
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
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