Search code examples
javaspringspring-integrationmessage-queueendpoint

How to send a message to a flow in spring integration?


Suppose the following flow:

public IntegrationFlow sendFlow() {
        return IntegrationFlow.from(inputChannel())
                .handle("something","someMethod")
                .channel(outputChannel())
                .get();
}

How I do a manually put a message in the input channel?

I would like something like this:

Message<String> message = MessageBuilder.withPayload("Test").build();
Something.submitToChannel("outputChannel", message);

Note: I am calling this from a Web Endpoint.

Thanks


Solution

  • Something like:

    @Autowire
    MessageChannel inputChannel;
    
    ...
    
    Message<String> message = MessageBuilder.withPayload("Test").build();
    this.inputChannel.send(message);