In the Spring integration the message channel can be configured like this:
<int:channel id="get_send_channel" />
<int:channel id="get_receive_channel">
<int:queue capacity='10' />
</int:channel>
<int-http:outbound-gateway id="get.outbound.gateway"
request-channel="get_send_channel"
url="http://localhost:8080/greeting"
http-method="GET" reply-channel="get_receive_channel"
expected-response-type="java.lang.String">
</int-http:outbound-gateway>
and used like this:
@SpringBootApplication
@ImportResource("http-outbound-gateway.xml")
public class HttpApplication {
@Autowired
@Qualifier("get_send_channel")
MessageChannel getSendChannel;
@Autowired
@Qualifier("get_receive_channel")
PollableChannel getReceiveChannel;
public static void main(String[] args) {
SpringApplication.run(HttpApplication.class, args);
}
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
Message<?> message = MessageBuilder.withPayload("").build();
getSendChannel.send(message);
System.out.println(getReceiveChannel.receive().getPayload());
};
}
How the MessageChannel can be created and registered dynamically?
Above code is from this example
I have now tried this
return IntegrationFlows.from(MessageChannels.rendezvous("getSend1"))
.handle(Http.outboundGateway("http://localhost:8080/greeting").httpMethod(HttpMethod.GET))
.channel(MessageChannels.queue("getReceive1")).get();
with default poller, but there is the message:
preReceive on channel 'getSend1'
postReceive on channel 'getSend1', message is null
Received no Message during the poll, returning 'false'
So the configuration seems to be incorrect and the message is not fetch from the URL.
It is working like this:
This does get for the first URL, then posts the answer the second URL and then posts the answer to third URL and gets the final answer.