-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Make SendToMethodReturnValueHandler and SubscriptionMethodReturnValueHandler customizable, to allow for pass-through of message headers #36179
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
base: main
Are you sure you want to change the base?
Conversation
| * Predicate to determine which header names from the input message should be propagated. | ||
| * If null, no headers are propagated (default behavior). | ||
| */ | ||
| private @Nullable Predicate<String> headerPropagationPredicate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify the name to headerFilter, and no need for Javadoc on the field as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I’ve renamed it to headerFilter and removed the field-level Javadoc to keep it consistent with existing style.
| * <p><b>Warning:</b> The predicate should avoid propagating or overwriting well-known protocol headers | ||
| * (e.g. headers starting with "simp", "content-type", etc.) to prevent breaking internal messaging semantics. | ||
| * </p> | ||
| * <p>If not set, no input headers are propagated (default behavior).</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of such a warning, which requires further investigation on its own, how about applying header propagation first, and then setting standard headers (like session id) second, so there is no possibility for overwriting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. I’ve removed the warning and updated the order so propagated headers are applied first, followed by standard headers, to avoid any possibility of overwriting.
| * <p>If not set, no input headers are propagated (default behavior).</p> | ||
| */ | ||
| public void setHeaderPropagationPredicate(@Nullable Predicate<String> predicate) { | ||
| this.headerPropagationPredicate = predicate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could allow multiple predicates to be provided, and combine those with Predicate#or, also changing the method name to add~ instead of set~.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. I’ve changed the API to addHeaderFilter and combined multiple predicates using Predicate#or.
|
I've applied the requested changes (renaming to headerFilter, switching to add~ method with Predicate#or logic, and adjusting the execution order). I've squashed the changes into the main commit to keep the history clean as per the contribution guide. Sorry for making the delta review slightly harder. |
…lers Signed-off-by: Junhwan Kim <musoyou1085@gmail.com>
This PR addresses issue #36168
Summary
Added an opt-in mechanism to selectively propagate headers from an input
Messageto the outboundMessagecreated by:SendToMethodReturnValueHandlerSubscriptionMethodReturnValueHandlerHeader propagation is controlled via a configurable
Predicate<String>.Default behavior remains unchanged: no headers are propagated unless explicitly configured.
Resolved Issue
Scope
MessageHeadersare populated by handler return value processing.Discussion Points
A discussion point is whether this is sufficient for the intended use cases, or if extending the mechanism to STOMP native headers should be considered separately rather than as part of this change.
Integration Test
Behavior was validated in an end-to-end WebSocket/STOMP scenario to ensure:
Only unit tests are committed in this PR.
If preferred, I can also include the integration test in this PR.