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

[RabbitMQ] Error policy with RabbitMQ is apparently not working #234

Open
marcospiresvortigo opened this issue Aug 5, 2024 · 7 comments

Comments

@marcospiresvortigo
Copy link

Error policy with RabbitMQ is apparently not working. I implemented the retry policy with the move after attempts, but I noticed that the failedAttempts is not being incremented when there is an error in the consumer. It stays in an infinite loop because of this. Here are my configurations.

var endpoint = new RabbitQueueConsumerEndpoint(consumerConfiguration.Origin)
                {
                    Connection = clientConfig,
                    Queue = queueConfig,
                    ErrorPolicy = ConfigureErrorPolicies(consumerConfiguration),
                };

                _ = builder.AddInbound(endpoint, consumerConfiguration.ActiveConsumers ?? 1);
private IErrorPolicy ConfigureErrorPolicies(ConsumerConfiguration consumerConfiguration)
        {
            var policyBuilder = new ErrorPolicyBuilder();

            var retryCount = consumerConfiguration.RetryCount ?? 3;
            var secondsBetweenRetry = consumerConfiguration.SecondsBetweenRetry ?? 10;
            var deadLetterSuffix = "dead-letter";

            var deadLetterEndpoint = GetProducerEndpoint($"{consumerConfiguration.Origin}-{deadLetterSuffix}",
                consumerConfiguration.BootstrapServerKeyDeadLetter ?? consumerConfiguration.BootstrapServerKey);

            policyBuilder.Retry(retryCount, TimeSpan.FromSeconds(secondsBetweenRetry))
                .ThenMove(deadLetterEndpoint!)
                .ThenSkip();

            return policyBuilder.Build();
        }

failedAttempts always remains 1 and ends up going into an infinite loop

image

@marcospiresvortigo
Copy link
Author

@BEagle1984 Could I be doing something wrong?

@BEagle1984
Copy link
Owner

I've to check this. I'll verify and report back. 👍

@marcospiresvortigo
Copy link
Author

thank you very much

@marcospiresvortigo
Copy link
Author

Another thing I noticed that I found strange, it says that it moved the message to the dead letter queue but when looking at the rabbitmq panel in the dead letter queue, no message arrived

image

Configuration move policy:
image

@BEagle1984
Copy link
Owner

Is this a sample project? Would it be possible to share the source code?

@marcospiresvortigo
Copy link
Author

It's a corporate project, it's a nuget package that we built around Silverback, in order to facilitate some configurations, we have a sample api just to validate that everything is ok, I'm going to remove the sensitive parts of the project and put together a poc with just the parts techniques and send them to you, I still send them to you today.

@BEagle1984
Copy link
Owner

Just a heads-up that RabbitMQ support will be deprecated in Silverback v5. You can find more details and the reasoning in the discussion here: #237.

Contributions are welcome if someone wants to take over maintaining it!

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

No branches or pull requests

2 participants