Spring integration: handle http error with oubound gateway

前端 未结 3 1067
星月不相逢
星月不相逢 2021-01-07 12:35

How can I handle exceptions in an http outbound gateway? When i receive status code 500 or 400..., an exception is shown. So What should I do to handle http error using spr

3条回答
  •  不知归路
    2021-01-07 13:13

    I would like to know why exception does'nt go to reply-channel

    Because it's natural to handle exceptions as, er, Exceptions.

    There are (at least) two ways to handle exceptions in Spring Integration.

    1. Add an error-channel and associated flow on whatever starts your flow (e.g. a gateway). The error channel gets an ErrorMessage with a MessagingException payload; the exception has two properties - the failedMessage and the cause.
    2. Add a ExpressionEvaluatingRequestHandlerAdvice (or a custom advice) to the gateway; see Adding Behavior to Endpoints.

提交回复
热议问题