0

I have a requirement where in I have to do Http Outbound call to an http endpoint in loop with different payload values, the calling function does not have to wait for the response received from the outbound calls, so basically the outbound calls will happen asynchronously in a loop.

Is there a way we can achieve this using the Http.outboundGateway

souvikc
  • 991
  • 1
  • 10
  • 25

1 Answers1

1

You just need to have an ExecutorChannel as an input for that HTTP Outbound Gateway endpoint. Something like:

.channel(MessageChannels.executor(someTaskExecutor))
.handle(Http.outboundGateway(...))

If you do that from some loop, then you should also have an id for that channel to inject and use for sending from your code. You also can consider to use a @MessagingGateway facade on top of that channel if you don't like to deal with MessageChannel API in your code.

See more info in docs:

https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints.html#gateway

https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#executor-channel

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118