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

Fix/routing key to queue name #172

Merged
merged 3 commits into from
Feb 11, 2022
Merged

Fix/routing key to queue name #172

merged 3 commits into from
Feb 11, 2022

Conversation

pat-goins
Copy link
Contributor

When republishing failed messages, publish to the _queueName the message came from instead of the message's routing key.

@ghost
Copy link

ghost commented Sep 28, 2021

CLA assistant check
All CLA requirements met.

@JatinSanghvi
Copy link
Contributor

JatinSanghvi commented Jan 29, 2022

@pat-goins - I debugged and found that both ea.routingKey and _queueName are set to same string. Did you encounter a case when the two differ?

@pat-goins
Copy link
Contributor Author

@JatinSanghvi - yes, the case we ran into when ea.routingKey (pulled from the queue message) is not the same as _queueName (queue where the message was pulled from) is from messages published through the direct exchange with multiple bindings. This could be the case when messages are routed by means other than the default exchange.

For example, message routing could be setup like the scenario in the "Direct exchange" section from the RabbitMQ docs:
image

If a message errored while processing from queue Q1, it would have ea.routingKey of orange, but _queueName of Q1. Prior to this change, the CreateHeadersAndRepublish/RepublishMessages methods would republish the message on the default exchange with a routingKey of orange. This would result in the message going nowhere.

If the intent is for an errored message to go back to the queue it came from, it should be republished on the default exchange with the routingKey of the originating _queueName.

@ghost ghost removed the Needs: Author Feedback label Feb 2, 2022
@pat-goins
Copy link
Contributor Author

To workaround the issue, we are doing something like this first thing inside our queue triggered functions:

var originalRoutingKey = incomingMessage.RoutingKey;
incomingMessage.RoutingKey = Constants.Queues.AuditQueueName;

@JatinSanghvi
Copy link
Contributor

Hi @pat-goins , thanks for the detailed explanation. I agree it makes sense to republish failed messages to default exchange with queue-name as the routing key. I should come back to the PR next week. Need to set some time to reproduce the error and verify your fix, and read on if there are any other alternate retry options (I doubt though) that works well with multiple bindings in place.

@JatinSanghvi JatinSanghvi merged commit f3ccff2 into Azure:dev Feb 11, 2022
@JatinSanghvi
Copy link
Contributor

Thanks @pat-goins 👍 I have merged the PR changes.

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

Successfully merging this pull request may close these issues.

2 participants