Skip to content

copy-input-headers property not working for function configuration #1273

Open
@allanewrynn

Description

@allanewrynn

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:

  1. it sets propagateInputHeaders to the value of copyInputHeaders - so true in my case
  2. 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
  1. That's it, that's all propagateInputHeaders does and it's not used anywhere else nor is copyInputHeaders 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<?>.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions