Reputation: 1006
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.
Upvotes: 0
Views: 382
Reputation: 121272
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
Upvotes: 1
Reputation: 174554
It depends on what you want to do; the error channel allows you to analyze the error and return different results based on the exception.
E.g. you can ask them to try again for a transient error or report the problem for a fatal error in the request.
The reply channel is generally not needed unless you want to do something like add a wire tap to log the reply. In fact, that channel ends up being bridged to the replyChannel header in the request (which is how the gateway correlates requests/replies.
Upvotes: 1