Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public AzureServiceBusFeature(IModule module) : base(module)
/// </summary>
public Action<AzureServiceBusOptions> AzureServiceBusOptions { get; set; } = _ => { };

/// <summary>
/// A delegate to create a <see cref="AzureServiceBusOptions"/> instance.
/// </summary>
public Func<IServiceProvider, ServiceBusProcessorOptions> ProcessorOptionsFactory { get; set; } = _ => new ServiceBusProcessorOptions();
Comment on lines +40 to +42

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Incorrect XML doc comment references wrong type

The summary says "A delegate to create a <see cref="AzureServiceBusOptions"/> instance" but the property creates a ServiceBusProcessorOptions instance, not an AzureServiceBusOptions.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/modules/servicebus/Elsa.ServiceBus.AzureServiceBus/Features/AzureServiceBusFeature.cs
Line: 40-42

Comment:
**Incorrect XML doc comment references wrong type**

The summary says "A delegate to create a `<see cref="AzureServiceBusOptions"/>` instance" but the property creates a `ServiceBusProcessorOptions` instance, not an `AzureServiceBusOptions`.

How can I resolve this? If you propose a fix, please make it concise.


/// <summary>
/// A delegate to create a <see cref="ServiceBusAdministrationClient"/> instance.
/// </summary>
Expand Down Expand Up @@ -68,6 +73,7 @@ public override void Apply()
Services
.AddSingleton(ServiceBusAdministrationClientFactory)
.AddSingleton(ServiceBusClientFactory)
.AddSingleton(ProcessorOptionsFactory)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Singleton ServiceBusProcessorOptions shared across all workers

ProcessorOptionsFactory is registered as a singleton, so every Worker instance — across all queues and topics — receives the exact same ServiceBusProcessorOptions object. If a user needs different concurrency, prefetch, or timeout settings per queue/topic, this design prevents it. Consider documenting this limitation or changing the approach (e.g., a Func<string, string?, ServiceBusProcessorOptions> keyed by queue/subscription).

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/modules/servicebus/Elsa.ServiceBus.AzureServiceBus/Features/AzureServiceBusFeature.cs
Line: 76

Comment:
**Singleton `ServiceBusProcessorOptions` shared across all workers**

`ProcessorOptionsFactory` is registered as a singleton, so every `Worker` instance — across all queues and topics — receives the exact same `ServiceBusProcessorOptions` object. If a user needs different concurrency, prefetch, or timeout settings per queue/topic, this design prevents it. Consider documenting this limitation or changing the approach (e.g., a `Func<string, string?, ServiceBusProcessorOptions>` keyed by queue/subscription).

How can I resolve this? If you propose a fix, please make it concise.

.AddSingleton<ConfigurationQueueTopicAndSubscriptionProvider>()
.AddSingleton<IWorkerManager, WorkerManager>()
.AddScoped<IServiceBusInitializer, ServiceBusInitializer>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Azure.Messaging.ServiceBus;
using Elsa.ServiceBus.AzureServiceBus.Models;

namespace Elsa.ServiceBus.AzureServiceBus.Options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ public class Worker : IAsyncDisposable
/// <summary>
/// Initializes a new instance of the <see cref="Worker"/> class.
/// </summary>
public Worker(string queueOrTopic, string? subscription, ServiceBusClient client, IServiceScopeFactory serviceScopeFactory, ILogger<Worker> logger)
public Worker(string queueOrTopic, string? subscription, ServiceBusClient client, ServiceBusProcessorOptions processorOptions, IServiceScopeFactory serviceScopeFactory, ILogger<Worker> logger)
{
QueueOrTopic = queueOrTopic;
Subscription = subscription == "" ? null : subscription;
_serviceScopeFactory = serviceScopeFactory;
_logger = logger;

var options = new ServiceBusProcessorOptions();
var processor = string.IsNullOrEmpty(subscription) ? client.CreateProcessor(queueOrTopic, options) : client.CreateProcessor(queueOrTopic, subscription, options);
var processor = string.IsNullOrEmpty(subscription) ? client.CreateProcessor(queueOrTopic, processorOptions) : client.CreateProcessor(queueOrTopic, subscription, processorOptions);

processor.ProcessMessageAsync += OnMessageReceivedAsync;
processor.ProcessErrorAsync += OnErrorAsync;
Expand Down