0

Given a Supplier function to produce messages in Spring Cloud Stream function, like:

@Bean
Supplier<Flux<Message<PayLoad>>> sendMessage() {
    return () -> getMessageSink().asFlux().log();
}

or this version

@Bean
Supplier<Flux<PayLoad>> sendMessage() {
    return () -> getMessageSink().asFlux().log();
}


and 

class PayLoad {
    public String header1;
    public String header2;
    public String message;
}

How would I configure the headers in my application.yml? I am assuming I need some form or spEl function or other.

I've tried using this from tickets filed, but to no avail and the documentation around this seems elusive.

spring:
  application:
    name: messages
  cloud:
    function:
      definition: sendMessage;consumeMessage
      configuration:
        sendMessage:
          input-header-mapping-expression:
            header1: spel.function.expression="payload.header1"
            header2: spel.function.expression="payload.header2"
Chuck C
  • 423
  • 1
  • 4
  • 12

1 Answers1

0

I am not quite sure what you're trying to accomplish nor are you showing getMessageSink() method implementation, but if you want a Supplier to produce a Message in the end, you can just return Message from your Suppliers with all the necessary headers.

Oleg Zhurakousky
  • 5,820
  • 16
  • 17
  • It just returns a Sinks.Many as recommended by Project Reactor after they deprecated EmitterProcessor. What I am trying to do, is have it set headers based on properties in the message object through declarative config and not resorting to a MessageBuilder and directly coding that functionality. – Chuck C Aug 27 '21 at 18:00