2016-08-04 17 views
2

私たちのアプリケーションではSpring Integrationを使用しました。最近、プロジェクトをspring boot 1.4 releaseにアップグレードしようとしました。spring java dsl 1.1.3を使用しています。最新のリリースでは、messageDriverChannelAdapterが非推奨になり、名前はmessageDriverChannelAdapterという新しいメソッドが作成されました。つまり、「r」が固定されています。1.1.3にアップグレードした後、エラーチャネルにエラーメッセージが配信されないspring integration java dsl

Java dsl 1.1.1のmessageDriverChannelAdapterを使用すると、統合フローは正常に動作しますが、失敗のケースでは1.1.3で失敗します(つまり、フローで例外が発生します)。ここで

は私のルーティング流れ

IntegrationFlows 
       .from(Jms.messageDriverChannelAdapter(listenerContainer()).errorChannel(errorChannel()) 
         .outputChannel(listenerDirectChannel())) 
       .channel(listenerDirectChannel()).transform(new JsonToChangeObjectTransformer()) 
       .channel(conversionOutChannel()).handle(CHANGED_OBJECT_LISTENER_IMPL, PROCESS_MESSAGE) 
       .channel(errorChannel()).handle(FAILED_MESSAGE_HANDLER_IMPL, HANDLE_ERROR).get(); 

私も試してみました

IntegrationFlows 
       .from(Jms.messageDrivenChannelAdapter(listenerContainer()) 
         .errorChannel(errorChannel()) 
         .outputChannel(listenerDirectChannel())) 
         .channel(listenerDirectChannel()) 
         .transform(new JsonToChangeObjectTransformer()) 
         .<Object, Boolean> route(p -> p instanceof ChangedObject, 
         m -> m.channelMapping("true", "conversionOutChannel").channelMapping("false", "errorChannel")) 
         .channel(conversionOutChannel()) 
         .handle(CHANGED_OBJECT_LISTENER_IMPL, PROCESS_MESSAGE).channel(errorChannel()) 
         .handle(FAILED_MESSAGE_HANDLER_IMPL, HANDLE_ERROR).get(); 

が、それでも運です

私の観察はメッセージチャネルをエラーに配信されることはありません(私がデバッグしているとして)最終的に起こるチャネルにメッセージを配置しようとし続ける。stackoverflowerror

例外:

org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:212) 
    at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:129) 
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115) 
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) 
    at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:160) 
    at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) 
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) 
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:423) 
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:373) 
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) 
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45) 
    at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105) 
    at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:292) 
    at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:212) 
    at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:129) 
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:115) 
    at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) 
    at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:160) 
    at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:121) 
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) 
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:423) 
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:373) 
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) 
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45) 

答えて

2

IntegrarionFlow定義が正しくありません。 あなたが最初.handle()の出力を意味

.handle(CHANGED_OBJECT_LISTENER_IMPL, PROCESS_MESSAGE) 
.channel(errorChannel()) 
.handle(FAILED_MESSAGE_HANDLER_IMPL, HANDLE_ERROR) 

を指定errorChannelに送信されます。 エラー処理の結果が良好です。いいえ...

あなたが期待していることは不明です。

エラーフローを分離してください。たとえば:https://github.com/spring-projects/spring-integration-java-dsl/issues/101

@Bean 
    public IntegrationFlow jmsMessageDrivenRedeliveryFlow() { 
     return IntegrationFlows 
       .from(Jms.messageDrivenChannelAdapter(this.jmsConnectionFactory) 
         .errorChannel(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME) 
         .destination("jmsMessageDriverRedelivery")) 
       .<String, String>transform(p -> { 
        throw new RuntimeException("intentional"); 
       }) 
       .get(); 
    } 

    @Bean 
    public CountDownLatch redeliveryLatch() { 
     return new CountDownLatch(3); 
    } 

    @Bean 
    public IntegrationFlow errorHandlingFlow() { 
     return IntegrationFlows.from(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME) 
       .handle(m -> { 
        MessagingException exception = (MessagingException) m.getPayload(); 
        redeliveryLatch().countDown(); 
        throw exception; 
       }) 
       .get(); 
    } 

はに関し、

関連する問題