question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cfg.UseRetry(); with the new Lambda-based retry policy configurator throw exceptions

See original GitHub issue

Getting exceptions that the RetryPolicy cannot be null, after i Upgraded to MT 3.5.4.

The service bus was not properly configured: [Failure] RetryPolicy must not be null

   private static IBusControl CreateIBusControl(Container container)
        {
            var configurator = container.GetInstance<IBusConfigurator>();

            var bus = configurator
                .CreateBus((cfg, host) =>
                {
                    cfg.ReceiveEndpoint<CollectCommand>(c =>
                    {
                        c.LoadFrom(container);
                    });
                    // works
                    cfg.UseRetry(Retry.Exponential(3, TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(2), TimeSpan.FromSeconds(5))); 
                    // doesn't work
                    cfg.UseRetry(r => Retry.Exponential(3, TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(2), TimeSpan.FromSeconds(5))); 
                })
                .ConfigureAwait(false)
                .GetAwaiter()
                .GetResult();
            return bus;
        }

Using this configurator helper class:

        public async Task<IBusControl> CreateBus(Action<IBusFactoryConfigurator, IHost> registrationAction = null, Action<IRetryConfigurator> retryGlobalPolicy = null)
        {
            var t = await Task.Run(() =>
            {
                var connUri = new Uri(Configuration.ConnectionUri);
                var bus = Bus.Factory.CreateUsingAzureServiceBus(cfg =>
                {
                    var host = cfg.Host(connUri, hst =>
                    {
                        hst.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(Configuration.Login, Configuration.Password);
                    });

                    registrationAction?.Invoke(cfg, host);
                    cfg.UseJsonSerializer();
                });
                return bus;
            });
            return t;
        }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
rille111commented, Feb 20, 2017

Ah, so simple a miss and course it works now when actually using the lambda! (using r.* not Retry.*) Much gratitude for the effort and time used to answer this issue!

0reactions
phatboygcommented, Feb 1, 2017

Pull request submitted, short answer, you weren’t using the lambda, you were just doing essentially a no-op in the method.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.net - MassTransit Retry policy throws System. ...
It's throwing a configuration exception because you didn't actually configure the retry. The retry usage is covered in the documentation.
Read more >
Exceptions
Shown below is a retry policy which attempts to deliver the message to a consumer five times before throwing the exception back up...
Read more >
Error handling and automatic retries in AWS Lambda
Function – Your function's code throws an exception or returns an error object. Runtime – The runtime terminated your function because it ran...
Read more >
Implementing Retry with Resilience4j
As a general policy, we want to retry when this exception is thrown. But there is one subclass of SeatsUnavailableException which we don't...
Read more >
Error Handling and Message Redelivery in MassTransit
With default bus configuration, exceptions are caught by MassTransit ... an e-mail logic... throw new Exception("Something's happened during processing.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found