Skip to content

Commit

Permalink
[Host.Outbox] Fails to retrieve bus when no child buses are in use #294
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Maruszak <[email protected]>
  • Loading branch information
zarusz committed Sep 11, 2024
1 parent 8b66f24 commit 51385b8
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 112 deletions.
2 changes: 1 addition & 1 deletion src/Host.Plugin.Properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Import Project="Common.NuGet.Properties.xml" />

<PropertyGroup>
<Version>2.5.2</Version>
<Version>2.5.3-rc1</Version>
</PropertyGroup>

</Project>
8 changes: 5 additions & 3 deletions src/SlimMessageBus.Host.Outbox/Services/OutboxSendingTask.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
namespace SlimMessageBus.Host.Outbox.Services;

using System.Threading;

using SlimMessageBus;
using SlimMessageBus.Host;
using SlimMessageBus.Host.Outbox;
Expand Down Expand Up @@ -356,7 +354,11 @@ private static IMasterMessageBus GetBus(ICompositeMessageBus compositeMessageBus
{
if (name != null && compositeMessageBus != null)
{
return compositeMessageBus.GetChildBus(name);
var childBus = compositeMessageBus.GetChildBus(name);
if (childBus != null)
{
return childBus;
}
}
if (messageBusTarget != null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SlimMessageBus.Host/MessageBusProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public IEnumerable<IMasterMessageBus> GetChildBuses()
{
return composite.GetChildBuses();
}
return Enumerable.Empty<IMasterMessageBus>();
return [];
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace SlimMessageBus.Host.Outbox.DbContext.Test;

public abstract class BaseOutboxIntegrationTest<T>(ITestOutputHelper testOutputHelper) : BaseIntegrationTest<T>(testOutputHelper)
{
protected async Task PerformDbOperation(Func<CustomerContext, IOutboxMigrationService, Task> action)
{
var scope = ServiceProvider!.CreateScope();
try
{
var context = scope.ServiceProvider.GetRequiredService<CustomerContext>();
var outboxMigrationService = scope.ServiceProvider.GetRequiredService<IOutboxMigrationService>();
await action(context, outboxMigrationService);
}
finally
{
await ((IAsyncDisposable)scope).DisposeAsync();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using SlimMessageBus.Host.Outbox.Services;
using SlimMessageBus.Host.RabbitMQ;


/// <summary>
/// This test should help to understand the runtime performance and overhead of the outbox feature.
/// It will generate the time measurements for a given transport (Azure DB + Azure SQL instance) as the baseline,
Expand All @@ -17,7 +18,7 @@
[Trait("Category", "Integration")] // for benchmarks
[Trait("Transport", "Outbox")]
[Collection(CustomerContext.Schema)]
public class OutboxBenchmarkTests(ITestOutputHelper testOutputHelper) : BaseIntegrationTest<OutboxBenchmarkTests>(testOutputHelper)
public class OutboxBenchmarkTests(ITestOutputHelper testOutputHelper) : BaseOutboxIntegrationTest<OutboxBenchmarkTests>(testOutputHelper)
{
private bool _useOutbox;
private BusType _testParamBusType;
Expand Down Expand Up @@ -127,21 +128,6 @@ protected override void SetupServices(ServiceCollection services, IConfiguration
x => x.MigrationsHistoryTable(HistoryRepository.DefaultTableName, CustomerContext.Schema)));
}

private async Task PerformDbOperation(Func<CustomerContext, IOutboxMigrationService, Task> action)
{
var scope = ServiceProvider!.CreateScope();
try
{
var context = scope.ServiceProvider.GetRequiredService<CustomerContext>();
var outboxMigrationService = scope.ServiceProvider.GetRequiredService<IOutboxMigrationService>();
await action(context, outboxMigrationService);
}
finally
{
await ((IAsyncDisposable)scope).DisposeAsync();
}
}

[Theory]
[InlineData([BusType.AzureSB, true, 1000])] // compare with outbox
[InlineData([BusType.RabbitMQ, true, 1000])]
Expand Down
Loading

0 comments on commit 51385b8

Please sign in to comment.