Make SendToMethodReturnValueHandler and SubscriptionMethodReturnValueHandler customizable, to allow for pass-through of message headers#36179
Conversation
...va/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java
Outdated
Show resolved
Hide resolved
...va/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java
Show resolved
Hide resolved
...va/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java
Outdated
Show resolved
Hide resolved
|
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>
…lers See gh-36179 Signed-off-by: Junhwan Kim <musoyou1085@gmail.com>
|
No problem, I added an additional property on |
|
Hi @rstoyanchev, When I was working on this PR, I found that the propagated headers didn't actually reach the STOMP client. There are two issues: Input side: STOMP custom headers (e.g. x-correlation-id) are stored inside the nativeHeaders sub-map, not as top-level MessageHeaders entries. So when headerFilter iterates over top-level keys, it never matches them. Output side: Even if headers were copied to the top-level MessageHeaders, StompEncoder.writeHeaders() only serializes entries from the nativeHeaders sub-map, so they would never be written to the outbound STOMP frame. That's why I had left it as a discussion point in the PR. Is the current scope what you intended, or should we extend propagation to STOMP native headers as well? If it makes sense to extend, I'd be happy to follow up with a PR. |
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.