2017-11-11 11 views
1

私は私の春の統合の設定をテストしようとしていますが、春の統合MessageDeliveryException

「MessageDeliveryException:Dispatcherは、チャネルのための加入者を持っていない」を受け付けております。

私はQueueChannelを使用していますが、私は(私がドキュメントで見ることができる)ハンドラが必要ではないと思います。

私はSpring Integration Java DSLを使用して、コンテキストを使用するのではなく、プログラムによって統合フローを定義しています。

import org.junit.Test; 
import org.junit.runner.RunWith; 
import org.springframework.integration.channel.QueueChannel; 
import org.springframework.integration.dsl.IntegrationFlows; 
import org.springframework.integration.dsl.channel.MessageChannels; 
import org.springframework.messaging.Message; 
import org.springframework.messaging.MessageChannel; 
import org.springframework.messaging.support.MessageBuilder; 
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 

@RunWith(SpringJUnit4ClassRunner.class) 
public class SimplifiedIntegrationTest { 
    @Test 
    public void simpleTest() { 
     MessageChannel inputChannel = MessageChannels.direct().get(); 
     QueueChannel outputChannel = MessageChannels.queue().get(); 
     IntegrationFlows.from(inputChannel).channel(outputChannel).get(); 

     inputChannel.send(MessageBuilder.withPayload("payload").build()); 

     Message<?> outMessage = outputChannel.receive(0); 
     Assert.notNull(outMessage); 
    } 
} 

答えて

2

IntegrationFlowは常にコンテキストとしてBeanとして登録する必要があります。私はあなたの考え方を違うものにしているのかどうかはわかりませんが、コンテキストでBeanとして登録しないので、特にBeanPostProcessorによって行われるフロー設定の魔法はありません。 。あなたの統合を手動フローあなたを登録した場合、あなたはエラー「Dispatcherは、チャネルのための加入者を持っていない」ことを得る理由です

IntegrationFlowContextを参照してください:https://docs.spring.io/spring-integration/docs/5.0.0.BUILD-SNAPSHOT/reference/html/java-dsl.html#java-dsl-runtime-flows

ドキュメントは春の統合5.0用ですが、同じようにIntegrationFlowContext動作すること。 Java DSL 1.2.x。