Particular / NServiceBus.AzureFunctions.Worker.ServiceBus

Process messages in AzureFunctions using the Azure Service Bus trigger and the NServiceBus message pipeline.
Other
6 stars 3 forks source link

Users expect transport and errors settings to be configured while these are being ignored #210

Open ramonsmits opened 1 year ago

ramonsmits commented 1 year ago

Some users try do to things like:

.UseNServiceBus(configuration =>
{
    var endpointConfiguration = configuration.AdvancedConfiguration;
    endpointConfiguration.License(NServiceBusLicense);
    endpointConfiguration.EnableInstallers();
    endpointConfiguration.SendFailedMessagesTo(errorQueueName);

    var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
    transport.ConnectionString(serviceBusNameSpaceFQDN);
    transport.CustomTokenCredential(new DefaultAzureCredential());

    var recoverability = endpointConfiguration.Recoverability();
    recoverability.Immediate(customizations: immediate => { mmediate.NumberOfRetries(3); });
    recoverability.Delayed(customizations: delayed => { delayed.NumberOfRetries(5).TimeIncrease(TimeSpan.FromSeconds(30)); });

    endpointConfiguration.LimitMessageProcessingConcurrencyTo(numberOfConsumers);

    // Disable the error queue to let NserviceBus native dead-lettering handle repeated failures:

    configuration.DoNotSendMessagesToErrorQueue();

    //@TODO: Add throttling behavior

})

The transport and concurrency limit settings are ignored but users are unaware of this. Same with DoNotSendMessagesToErrorQueue which overrides SendFailedMessagesTo. These conflicting settings should result in an endpoint not being able to start or even better. Such APIs should not even be available when using Azure Functions.

SeanFeldman commented 1 year ago

That'd be nice.

Regarding sending messages to the error queue, could be possible with middleware.

mikeminutillo commented 11 months ago

In the following PR we are detecting when someone uses APIs to configure the transport in ways that do not function correctly in a serverless context:

The documentation for DoNotSendMessagesToErrorQueue states

Disables moving messages to the error queue even if an error queue name is configured.

That seems to imply that you are supposed to be allowed to configure both by design.

jpalac commented 1 month ago

@ramonsmits given the above comment, is this issue still valid or can it be closed?

ramonsmits commented 1 month ago

No, from my pov the Roslyn analyzer is a workaround for a badly designed API. APIs that don't make sense in the context should not even be available.

Either a different endpointconfiguration should be used or the endpoint configuration should not provide these and expose such APIs differently