Using NServiceBus v7.4.6 plus .NET Core 3.1 and getting the exception
The given key NServiceBus.RecoverabilitySettings was not present in the dictionary.
with the code below when trying to get RecoverabilitySettings
in the feature. What could be wrong?
public class MyFeature : Feature
{
protected override void Setup(FeatureConfigurationContext context)
{
var recoverability = context.Settings.Get<RecoverabilitySettings>();
recoverability.Failed(settings => settings.OnMessageSentToErrorQueue(message =>
{
Console.WriteLine(message.MessageId);
return Task.CompletedTask;
}));
}
}
public static class Program
{
public static async Task Main()
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var host = Host
.CreateDefaultBuilder()
.UseConsoleLifetime()
.UseNServiceBus(c =>
{
var endpointConfiguration = new EndpointConfiguration("MyEndpoint");
var connectionString = configuration.GetConnectionString("AzureServiceBusTransport");
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
transport.ConnectionString(connectionString);
endpointConfiguration.EnableFeature<MyFeature>();
return endpointConfiguration;
})
.Build();
await host.RunAsync();
}
}
Update
I try to update the feature from older version 7 of NServiceBus to the latest one where ErrorsNotifications.MessageSentToErrorQueue
become obsolete. The old feature code was like
public class MyOldFeature : Feature
{
protected override void Setup(FeatureConfigurationContext context)
{
var notifications = context.Settings.Get<Notifications>();
notifications.Errors.MessageSentToErrorQueue += this.OnMessageSentToErrorQueue;
}
private void OnMessageSentToErrorQueue(object sender, FailedMessage message)
{
Console.WriteLine(message.MessageId);
}
}