Description
Describe the bug
spring-cloud-function-context 4.2.2
spring-boot 3.4.4
spring-boot-starter-amqp 3.4.4
I have a Function bean:
@Bean
public Function<Message<?>, Object> transform() {
return message -> {
return transformerService.transform(message);
};
}
which accepts a Message<?> and returns an Object. I want to propagate the headers from the input message to the output.
This documentation input_header_propagation tells me that I can set a property
spring.cloud.function.configuration.transform.copy-input-headers=true
and the input headers will be propagated to the output.
Unfortunately this does not work.
The only way I can get it to work is by manually copying the headers and return a Message<?> instead of an Object.
I stepped through the debugger of SimpleFunctionRegistry.java
and what I saw:
- it sets
propagateInputHeaders
to the value of copyInputHeaders - so true in my case propagateInputHeaders
is only used here
private boolean isExtractPayload(Message<?> message, Type type) {
if (this.propagateInputHeaders || this.isRoutingFunction() || FunctionTypeUtils.isMessage(type)) {
return false;
}
....
....
// rest of code
- That's it, that's all
propagateInputHeaders
does and it's not used anywhere else nor iscopyInputHeaders
used anywhere else.
It would be great if the property worked so that a manual copy in the code isn't necessary and it would allow a Function to return an Object rather than forced to return a Message<?>.