Enhance configuration options for MassTransit
This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json.
This commit is contained in:
parent
065765307b
commit
5d9e886e7f
|
|
@ -16,6 +16,7 @@ using Elsa.MongoDb.Extensions;
|
|||
using Elsa.MongoDb.Modules.Identity;
|
||||
using Elsa.MongoDb.Modules.Management;
|
||||
using Elsa.MongoDb.Modules.Runtime;
|
||||
using MassTransit;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Proto.Persistence.Sqlite;
|
||||
|
|
@ -203,12 +204,26 @@ services
|
|||
{
|
||||
if (useMassTransitAzureServiceBus)
|
||||
{
|
||||
massTransit.UseAzureServiceBus(azureServiceBusConnectionString, asb => asb.ConfigureServiceBus = bus => { bus.PrefetchCount = 4; });
|
||||
massTransit.UseAzureServiceBus(azureServiceBusConnectionString, serviceBusFeature => serviceBusFeature.ConfigureServiceBus = bus =>
|
||||
{
|
||||
bus.PrefetchCount = 4;
|
||||
bus.LockDuration = TimeSpan.FromMinutes(5);
|
||||
bus.MaxConcurrentCalls = 32;
|
||||
bus.MaxDeliveryCount = 8;
|
||||
// etc.
|
||||
});
|
||||
}
|
||||
|
||||
if (useMassTransitRabbitMq)
|
||||
{
|
||||
massTransit.UseRabbitMq(rabbitMqConnectionString, rabbit => rabbit.ConfigureServiceBus = bus => { bus.PrefetchCount = 4; });
|
||||
massTransit.UseRabbitMq(rabbitMqConnectionString, rabbit => rabbit.ConfigureServiceBus = bus =>
|
||||
{
|
||||
bus.PrefetchCount = 4;
|
||||
bus.Durable = true;
|
||||
bus.AutoDelete = false;
|
||||
bus.ConcurrentMessageLimit = 32;
|
||||
// etc.
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"Sqlite": "Data Source=App_Data/elsa.sqlite.db;Cache=Shared;",
|
||||
"MongoDb": "mongodb://localhost:27017/elsa-workflows",
|
||||
"AzureServiceBus": "",
|
||||
"RabbitMq": ""
|
||||
"RabbitMq": "amqp://guest:guest@localhost:5672/elsa"
|
||||
},
|
||||
"Smtp": {
|
||||
"Host": "localhost",
|
||||
|
|
|
|||
|
|
@ -25,6 +25,11 @@ public class MassTransitWorkflowDispatcherFeature : FeatureBase
|
|||
public MassTransitWorkflowDispatcherFeature(IModule module) : base(module)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the MassTransit workflow dispatcher.
|
||||
/// </summary>
|
||||
public Action<MassTransitWorkflowDispatcherOptions>? ConfigureDispatcherOptions { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Configure()
|
||||
|
|
@ -36,7 +41,10 @@ public class MassTransitWorkflowDispatcherFeature : FeatureBase
|
|||
/// <inheritdoc />
|
||||
public override void Apply()
|
||||
{
|
||||
Services.AddOptions<MassTransitWorkflowDispatcherOptions>();
|
||||
var options = Services.AddOptions<MassTransitWorkflowDispatcherOptions>();
|
||||
|
||||
if (ConfigureDispatcherOptions != null)
|
||||
options.Configure(ConfigureDispatcherOptions);
|
||||
|
||||
var queueName = KebabCaseEndpointNameFormatter.Instance.Consumer<DispatchWorkflowRequestConsumer>();
|
||||
var queueAddress = new Uri($"queue:elsa-{queueName}");
|
||||
|
|
|
|||
Loading…
Reference in a new issue