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

Improve Extensibility of RepublishMessageRecoverer #1382

Closed
bastiat opened this issue Nov 2, 2021 · 1 comment · Fixed by #1527
Closed

Improve Extensibility of RepublishMessageRecoverer #1382

bastiat opened this issue Nov 2, 2021 · 1 comment · Fixed by #1527

Comments

@bastiat
Copy link

bastiat commented Nov 2, 2021

Enhancement

Hello,

How do you find idea of making String RepublishMessageRecoverer.prefixedOriginalRoutingKey protected instead of private?
It would make if possible to override prefixedOriginalRoutingKey to send back with different routing key depending on message.

My case is I would like to add custom headers to message that is moved to DLQ (x-dead-letter-exchange) that is associated with a queue.
RejectAndDontRequeueRecoverer would be fine, but I can't add custom headers there.
RepublishMessageRecoverer is good for headers, but it sends back to wrong exchange - I would like to make it behave the same as RejectAndDontRequeueRecoverer about used DLQ/exchange.
Now I will have to override whole recover() with copy paste and write custom private prefixedOriginalRoutingKey.
If prefixedOriginalRoutingKey were protected, it would be sufficient to override it without necessity of copy-paste recover() and other private methods used by it.

I would like to:

@Override
protected String prefixedOriginalRoutingKey(Message message) {
            return message.getMessageProperties().getConsumerQueue() + ".dead.letter";
}

Regarding what @garyrussell wrote
but making that method protected won't change the exchange - you can set the errorExchangeName for that (also errorRoutingKey and then the prefix won't be used).

It seems to me that I can't get what I need with errorExchangeName or errorRoutingKey - they are static and I need to compute DLQ dynamically. If it do is possible, please show how could I implement it.

Thanks and Regards.

@garyrussell
Copy link
Contributor

I am fine with making it protected; my comment was related to this...

is good for headers, but it sends back to wrong exchange

...there is (currently) no mechanism to choose a different exchange at runtime.

Feel free to submit a PR with the changes you need.

@garyrussell garyrussell added this to the Backlog milestone Nov 2, 2021
@garyrussell garyrussell self-assigned this Oct 27, 2022
@garyrussell garyrussell modified the milestones: Backlog, 3.0.0 Oct 27, 2022
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Oct 27, 2022
Resolves spring-projects#1382

Add expressions; make private method protected.

**cherry-pick to 2.4.x**
artembilan pushed a commit that referenced this issue Oct 28, 2022
Resolves #1382

Add expressions; make private method protected.

**cherry-pick to 2.4.x**
artembilan pushed a commit that referenced this issue Oct 28, 2022
Resolves #1382

Add expressions; make private method protected.

**cherry-pick to 2.4.x**
garyrussell added a commit that referenced this issue Oct 31, 2022
garyrussell added a commit that referenced this issue Nov 1, 2022
@garyrussell garyrussell changed the title Make RepublishMessageRecoverer.prefixedOriginalRoutingKey protected instead of private Improve Extensibility of RepublishMessageRecoverer Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants