Q:

Spring Integration error channel in gateways

I have a rest controller that will trigger my gateway method
<int:gateway id="bGatewayService"
        service-interface="nd.l.eai.gw.BGateway"
        default-reply-channel="dest-channel"
        default-request-timeout="5000" default-reply-timeout="5000">        
        <int:method name="m1" request-channel="atbInChannel"/>
        <int:method name="m2" request-channel="btuInChannel"/>
    </int:gateway>

the application works ok. I don't have error-channel [as you see above]
My question is - what is the advantage of the error-channel, as I am getting the 500 or Bad Request without it. Should I create an error channel and include in the above?
Also I am using default reply channel, is that ok? or should I add reply-channel to each method? I have another gateway that has 10 methods.

A:

You don't need error-channel if you are not going to have some compensation flow. If just throw an exception as is OK with your use-case, then don't configure any error-channel.
In most cases we don't need a reply-channel as well, even that default-reply-channel. When you don't use an output-channel in the last endpoint of your flow, the replyChannel header is going to be use. We only need that reply-channel for use-cases where we need some kind of pub-sub reply message processing, where we would like to send a reply message not only as a return for gateway method call, but also to some other flow.
More info is in the Docs: https://docs.spring.io/spring-integration/docs/current/reference/html/#gateway

