elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.05k stars 1.1k forks source link

Unable to install Elsa.Rebus.AzureServiceBus on .NET6 + workaround #3183

Open MariusVuscanNx opened 1 year ago

MariusVuscanNx commented 1 year ago

We had some issues with installing Elsa.Rebus.AzureServiceBus package. The errors are present in the following picture:

image

The problem is that the package has a dependency on Rebus.AzureServiceBus 9.0.8. This package has dependencies on older versions of some packages. In .NET 6 those packages have newer versions. Therefore, installing that package will result in a downgrade error message.

Workaround: We installed an older version of the Rebus.AzureServiceBus (8.1.5) package directly and constructed the middleware based on the one from Elsa.Rebus.AzureServiceBus. The code:

public static ElsaOptionsBuilder AddAzureServiceBus(this ElsaOptionsBuilder options, string connectionString)
        {
            return options
                .UseServiceBus(context =>
                {
                    var queueName = context.QueueName;

                    context.Configurer
                        .Transport(t =>
                        {
                            if (queueName.Length > 50)
                                queueName = queueName.Substring(queueName.Length - 50);

                            t.UseNativeDeadlettering();
                            var transport = t.UseAzureServiceBus(connectionString, queueName);

                            if (context.AutoDeleteOnIdle)
                                transport.SetAutoDeleteOnIdle(TimeSpan.FromMinutes(5));
                        });
                });
        }
sfmskywalker commented 1 year ago

Thank you for providing the workaround!