Skip to content

GH-3989 Consider the custom name of the reply topic name in sendAndRec… #3994

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

Closed
wants to merge 1 commit into from

Conversation

mipo256
Copy link
Contributor

@mipo256 mipo256 commented Jul 14, 2025

Closes #3989

WIP, writing tests

@mipo256 mipo256 force-pushed the GH-3989 branch 8 times, most recently from 99a759d to 95c9166 Compare July 14, 2025 15:00
@sobychacko
Copy link
Contributor

@mipo256 PR build is failing, just letting you know.

@mipo256
Copy link
Contributor Author

mipo256 commented Jul 14, 2025

Hey @sobychacko ! I know, thanks! I'll fix the checkstyle violations shortly and then ping you :)

@mipo256 mipo256 marked this pull request as ready for review July 15, 2025 11:16
@mipo256
Copy link
Contributor Author

mipo256 commented Jul 15, 2025

Hey guys @sobychacko, @artembilan.

I've added some test cases for this scenario and introduced minor polishing, the PR is ready for review

@@ -35,8 +35,16 @@ public final class CorrelationKey {

private final byte[] correlationId;

/**
* Cached hex representation of the {@link #correlationId}.
* TODO: Migrate to stable values JEP 502
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate what you mean by migrate to JEP 502 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that in JEP 502 we would have stable values in Java, which are lazily initilized final fields. The lazily computed hashcode and hex representation of correlation id is exactly that use case.

@mipo256
Copy link
Contributor Author

mipo256 commented Jul 16, 2025

Hey @sobychacko, can you please re-review? I've answered you questions and fixed the comments that I think we both agree upon.

Thank you!

Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have the title of PR and commit message fixed for the typo?
That Consder word is wrong.
Thanks

@mipo256 mipo256 changed the title GH-3989 Consder the custom name of the reply topic name in sendAndRec… GH-3989 Consider the custom name of the reply topic name in sendAndRec… Jul 18, 2025
@mipo256
Copy link
Contributor Author

mipo256 commented Jul 18, 2025

Hey @artembilan, sure, it's done

@mipo256 mipo256 requested a review from artembilan July 18, 2025 09:57
Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know issue in details to be sure why we didn't have this feature for years, but it still worth to look into sending-messages.adoc to determine the reason.
And mention this new feature over there if that is what we would want.

Thanks

@artembilan
Copy link
Member

OK. I see @sobychacko said in the issue:

not using this.replyTopicHeaderName and directly checking against KafkaHeaders.REPLY_TOPIC in that conditional seems like a bug.

So, feels like this fix is supposed to be a back-port candidate.
Therefore, indeed, all the not relevant changes have to go.

@mipo256
Copy link
Contributor Author

mipo256 commented Jul 19, 2025

With all due respect Artem @artembilan, I do not think you're fully in the context of the problem.

I’m not sure how that relates to the issue. The length are supposed to be the same.

No, it is not. And it is the core of the issue. The custom reply header is considered already, and it works fine. The problem arises when the the custom reply header is overridden by the user via public API, and in this case the custom reply header is sent in the kafka message two times. It's get duplicated, see from the original issue:

This leads to duplicate headers (reply topic and reply partition) being set. In my case, this is particularly problematic because I have to provide the reply partition header in a different form - but the ReplyingKafkaTemplate overwrites it with its own header.

I'm reading your code review and I think we have a misunderstanding here. I'll fix all your comments regarding the code style etc, no problem, I'm just making sure we're on the same page.

@mipo256
Copy link
Contributor Author

mipo256 commented Jul 19, 2025

As I said: we are aiming to back -port the fix.

My 2 cents. I'm not sure it is a good backport candidate.

This is the bug, and when it get's fixed, then hypothetically, when previously producer produced 4 headers in the message (two for custom reply header, and two for custom reply partition), now it will produce 4.

For me at least, it is highly questionable if this change is backward compatible, since the consumers now will receive de-facto different messages (4 vs 2 headers).

CC : @sobychacko @artembilan

@mipo256 mipo256 force-pushed the GH-3989 branch 3 times, most recently from 738a6ca to 6290a30 Compare July 19, 2025 12:48
@mipo256 mipo256 requested a review from artembilan July 19, 2025 12:48
@sobychacko
Copy link
Contributor

Merged via 97f482a.

@sobychacko sobychacko closed this Jul 21, 2025
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

Successfully merging this pull request may close these issues.

ReplyingKafkaTemplate checks for default reply header name instead of custom one
3 participants