vishal sharma
vishal sharma

Reputation: 1

Custom Message Headers support when using functional bean definitons

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.

Upvotes: 0

Views: 131

Answers (0)

Related Questions