2016-08-12 7 views
2

次のSpring Integrationコンフィグレーションでは、MVCコントローラからゲートウェイメソッドを呼び出してコントローラを返すことができますが、統合フローはコントローラをブロックしない別のスレッド。Spring統合フローasyncでのエラー処理

しかし、この非同期フローでエラーハンドラを動作させる方法を理解できません。私のゲートウェイにはエラーチャンネルが定義されていますが、何らかの理由で例外が発生することはありません。代わりに、LoggingHandlerが呼び出されることがわかります。

@Bean 
IntegrationFlow mainInteractiveFlow() { 
    return IntegrationFlows.from(
      MessageChannels.executor("input", executor)) 
      .split() 
      .channel(MessageChannels.executor(executor)) 
      .transform(transformer) 
      .handle(genericMessageHandler, "validate") 
      .handle(genericMessageHandler, "checkSubscription") 
      .handle(interactiveMessageService, "handle") 
      .<Task, String>route(p -> p.getKind().name(), 
        m -> m.channelMapping(TaskKind.ABC.name(), "attachInteractiveChannel")) 
      .get(); 
} 

@Bean 
IntegrationFlow attachInteractiveChannelFlow() { 
    return IntegrationFlows.from(
      MessageChannels.direct("attachInteractiveChannel")) 
      .handle(issueRouterService) 
      .get(); 
} 

@Bean 
IntegrationFlow interactiveExceptionChannelFlow() { 
    return IntegrationFlows.from(interactiveExceptionChannel()) 
      .handle(errorHandler, "handleErrorMessage") 
      .get(); 
} 

@Bean 
MessageChannel interactiveExceptionChannel() { 
    return MessageChannels.direct("interactiveExceptionChannel").get(); 
} 

ゲートウェイ:

@MessagingGateway(errorChannel = "interactiveExceptionChannel") 
public interface InteractiveSlackGW { 

    @Gateway(requestChannel = "input") 
    void interactiveMessage(Collection<Request> messages); 

} 

私は私の例外は私のエラーハンドラによって処理される非同期統合の流れに起こって見るために何をすべき?

答えて

2

戻り値がゲートウェイの場合、返信は不要であるため、メッセージヘッダーに応答/エラーチャネルが追加されません。呼び出しスレッドで実行されると、例外が呼び出し側にスローされます。非同期フローの場合、例外はデフォルトのerrorChannel(ログアダプタが接続されています)になります。

このシナリオでは、エラーチャネルにerrorChannelヘッダーを設定するヘッダーエンリッチャーを追加する必要があります。

これを自動的に実行する必要がありますが、現時点では発生しません。

私はJIRA Issueを開封しました。

+0

ああ、すべてを説明しています。ありがとう、ゲーリー。 –

+0

'@GatewayHeader(name =" errorChannel "、expression =" @ interactiveExceptionChannel ")'のようなものを考えてみましょう。私はSpring Integration 5.0の中でこれがちょうどいいと思います。 –

関連する問題