Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DelayedRedelivery with a Consumer factory #1063

Closed
thurfir opened this issue Feb 12, 2018 · 10 comments
Closed

DelayedRedelivery with a Consumer factory #1063

thurfir opened this issue Feb 12, 2018 · 10 comments

Comments

@thurfir
Copy link

thurfir commented Feb 12, 2018

Hi,

Sorry if this is the wrong communication channel, I first posted on the google group but my post seems to have disappeared.

We would like to implement a retry process for our queues. We are looking to run retries with long delays (~1 hour) so non-blocking jobs are required.
From what I read DelayedRedelivery is the way to achieve that in masstransit?

I found a few examples on these topics about how to use DelayedRedelivery like this one: #646

however I was not able to apply the UseScheduledRedelivery to test it by myself: we are using the non-generic .Consumer() method on our endpoints, and there is no configuration parameter available.

Here is our code:

                cfg.ReceiveEndpoint(host, queue.QueueName, e =>
                {
                    // create the request consumer
                    e.Consumer(queue.ConsumerType, type => queue.ConsumerBuilder(type));

Is there another way to apply this configuration (maybe from the IConsumer) ?

Thanks for your help.

@phatboyg
Copy link
Member

There is a way, but it isn't obvious how to use it. Let me think about this one and see if I can make it easier.

phatboyg added a commit that referenced this issue Feb 12, 2018
…changeRedelivery without knowing message types #1063
@phatboyg
Copy link
Member

So I added extensions to support this, which work for consumers and sagas.

@thurfir
Copy link
Author

thurfir commented Feb 13, 2018

Much appreciated @phatboyg , this is exactly what i was looking for!

We will test it in our solution today and apply it as soon as it moves to release.

@thurfir
Copy link
Author

thurfir commented Feb 15, 2018

Hello @phatboyg , there seems to be an issue with the new extensions + the non-generic consumer, the retries never occurs:

            var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                cfg.UseDelayedExchangeMessageScheduler();

                var host = cfg.Host(new Uri("rabbitmq://localhost"), "main", h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                cfg.ReceiveEndpoint(host, "mytempqueue", e =>
                {
                    e.UseDelayedRedelivery(r => r.Intervals(100, 200));

                    //e.Consumer<TestConsumer>();
                    e.Consumer(typeof(TestConsumer), type => new TestConsumer());
                });
            });

            await busControl.StartAsync();

            var uri = new Uri("rabbitmq://localhost/mytempqueue");

            var sendEndpoint = await busControl.GetSendEndpoint(uri);
            await sendEndpoint.Send(new TestRequest { Data = "ok" });

When I switch to e.Consumer<TestConsumer>(); the retries are triggered properly.

Update: Same issue with UseInMemoryScheduler + UseScheduledRedelivery.

@phatboyg
Copy link
Member

This should be fixed in develop, will be released at the next version (might be 5.x instead of 4.1, but whatever).

@phatboyg
Copy link
Member

There was more work required for this to work, and it's coming.

@thurfir
Copy link
Author

thurfir commented Feb 26, 2018

Thank you @phatboyg , we really appreciate the time you are spending on this issue!

@phatboyg
Copy link
Member

The latest develop should have this all sorted out now. There is a new extension methods to setup retry inside of redelivery.

e.UseDelayedRedelivery(...);
e.UseMessageRetry(...);

This properly nestes retry inside of redelivery.

@thurfir
Copy link
Author

thurfir commented Feb 28, 2018

I'm a bit confused, should we replace .UseDelayedRedelivery(..) by .UseMessageRetry(..) ?
Is it the same method for .UseScheduledRedelivery(..) ?

@phatboyg
Copy link
Member

If you want both retry and redelivery you need to use both in the order I specified above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants