Skip to content

Commit

Permalink
Added config switch to enable/disable the in-memory outbox. (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgernand authored Jan 10, 2023
1 parent bdbbe3b commit add78b4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ public sealed class AzureServiceBusMessagingOptions
/// </summary>
public AzureServiceBusMessagingOptions()
{
ConnectionStrings = new ConnectionStrings();
this.ConnectionStrings = new ConnectionStrings();
}

/// <summary>
/// Gets or sets a value indicating whether the in-memory outbox is enabled.
/// </summary>
/// <value>
/// <c>true</c> if the in-memory outbox is enabled; otherwise, <c>false</c>.
/// </value>
public bool InMemoryOutboxEnabled { get; set; } = true;

/// <summary>
/// Gets or sets the name of the connection string to use.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void ConfigureTransport(IBusRegistrationConfigurator configurator, IServi
configurator.UsingAzureServiceBus((ctx, cfg) =>
{
bool isTransactionalOutboxModuleLoaded = context.Items.ContainsKey("IsTransactionalOutboxModuleLoaded");
if(!isTransactionalOutboxModuleLoaded)
if(!isTransactionalOutboxModuleLoaded && options.InMemoryOutboxEnabled)
{
cfg.UseInMemoryOutbox();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System.Text.Json;
using Fluxera.Enumeration.SystemTextJson;
using Fluxera.Extensions.Hosting.Modules.Configuration;
using Fluxera.Extensions.Hosting.Modules.Messaging.Filters;
using Fluxera.Spatial.SystemTextJson;
using Fluxera.StronglyTypedId.SystemTextJson;
Expand All @@ -15,10 +16,12 @@ internal sealed class TransportContributor : ITransportContributor
/// <inheritdoc />
public void ConfigureTransport(IBusRegistrationConfigurator configurator, IServiceConfigurationContext context)
{
InMemoryMessagingOptions options = context.Services.GetOptions<InMemoryMessagingOptions>();

configurator.UsingInMemory((ctx, cfg) =>
{
bool isTransactionalOutboxModuleLoaded = context.Items.ContainsKey("IsTransactionalOutboxModuleLoaded");
if(!isTransactionalOutboxModuleLoaded)
if(!isTransactionalOutboxModuleLoaded && options.InMemoryOutboxEnabled)
{
cfg.UseInMemoryOutbox();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,13 @@ public sealed class InMemoryMessagingOptions
/// Specify the number of concurrent messages that can be consumed (separate from prefetch count).
/// </summary>
public int? ConcurrentMessageLimit { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the in-memory outbox is enabled.
/// </summary>
/// <value>
/// <c>true</c> if the in-memory outbox is enabled; otherwise, <c>false</c>.
/// </value>
public bool InMemoryOutboxEnabled { get; set; } = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void ConfigureTransport(IBusRegistrationConfigurator configurator, IServi
configurator.UsingRabbitMq((ctx, cfg) =>
{
bool isTransactionalOutboxModuleLoaded = context.Items.ContainsKey("IsTransactionalOutboxModuleLoaded");
if(!isTransactionalOutboxModuleLoaded)
if(!isTransactionalOutboxModuleLoaded && options.InMemoryOutboxEnabled)
{
cfg.UseInMemoryOutbox();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ public RabbitMqMessagingOptions()
this.ConnectionStrings = new ConnectionStrings();
}

/// <summary>
/// Gets or sets a value indicating whether the in-memory outbox is enabled.
/// </summary>
/// <value>
/// <c>true</c> if the in-memory outbox is enabled; otherwise, <c>false</c>.
/// </value>
public bool InMemoryOutboxEnabled { get; set; } = true;

/// <summary>
/// Gets or sets the name of the connection string to use.
/// </summary>
Expand Down

0 comments on commit add78b4

Please sign in to comment.