0

I am unable to extract custom Message headers in a Function<Message,?> when using functional bean definitions for Spring cloud function.

Is there any way to extract the user defined Messsage headers that were passed in the request ?

@SpringBootConfiguration
public class Demo implements Function<Message<String>,String> {

    public static void main(String[] args) {
        FunctionalSpringApplication.run(Demo.class,args);

    }
    @Override   
    public String apply(Message<String> stringMessage) {
        final MessageHeaders headers = stringMessage.getHeaders();
        headers.entrySet().forEach(System.out::println);
        return stringMessage.getPayload().toUpperCase();
    }
}

Only 3 fixed headers are passed everytime

  1. scf-func-name
  2. id
  3. timestamp

However, any custom headers that are passed in the request are not available in the message headers.

  • What version of spring-cloud-function you are using? – Oleg Zhurakousky Jan 24 '22 at 09:05
  • Also, here is the test cases that validates it - https://github.com/spring-cloud/spring-cloud-function/blob/main/spring-cloud-function-context/src/test/java/org/springframework/cloud/function/context/HybridFunctionalRegistrationTests.java#L57 – Oleg Zhurakousky Jan 24 '22 at 15:25
  • @OlegZhurakousky thanks for your reply. I am using spring-cloud version 2020.0.4 and spring-cloud-starter-function-webflux dependency. One thing I noticed from the test case is that I am not using --spring.functional.enabled=false. If you want I can try to add a link to the code for you to look. – vishal sharma Jan 26 '22 at 16:19
  • Also the spring-boot version is 2.5.4 – vishal sharma Jan 26 '22 at 16:31

0 Answers0