2017-05-10 9 views
-1
<int-http:inbound-gateway id="inboundGateway" 
         path="inboundEndpoint" 
         supported-methods="PUT" request-payload-type="customJsonType" 
         message-converters="jacksonJSONConverter" 
         merge-with-default-converters="true" 
         error-channel="inboundErrorChannel" 
         request-channel="SendChannel" 
         reply-channel="ReplyChannel"/> 

<int:channel id="SendChannel" /> 

<int:channel id="ReplyChannel" /> 

<int:channel id="inboundErrorChannel" /> 

<int:service-activator input-channel="inboundErrorChannel" ref="customErrorHandler" method="handle"/> 

<bean id="customErrorHandler" class="CustomErrorHandler"/> 

そしてここにハンドラがあります。http-inbound-gatewayのerror-channelがメッセージ変換プログラムからメッセージング例外をキャッチしない

public class CustomErrorHandler { 

    private Logger logger = LoggerFactory.getLogger(this.getClass()); 
    public void handle(Message<?> message) { 
    logger.debug("payload: {}", message.getPayload()); 
    } 
} 

私は/ inboundEndpointにPUT curlコマンドを送って、 それは、このようなエラーメッセージを返す

org.springframework.messaging.MessagingException: Could not convert request: no suitable HttpMessageConverter found for expected type 

しかしSeerealErrorHandlerは何もキャッチしていません。 (CustomErrorHandlerのログはありません)

春のデフォルトエラーハンドラーは、ユーザーへの返信応答を管理しているようです。

エラーチャネルでこれらのエラー(メッセージコンバータから)をキャッチするにはどうすればよいですか?

  • 問題は、メッセージコンバータからの例外はキャッチされず、SendChannelとReplyChannelの間で発生したその他の例外はキャッチされません。メッセージコンバータから例外をどのように捕捉できますか?

答えて

0

変換エラーが早すぎるプロセスで発生します。エラーチャネルはゲートウェイの下流で発生するエラーのみを取得します。

おそらくサーブレットフィルタで何かできます。

関連する問題