2016-04-03 8 views
2

私にとって、これはちょうど可能な最も簡単なスプリング統合の例のようです。私はsi4demoから学びたいと思っています。私はそれを実行したときしかし、私はこの例外を取得する:スレッド内なぜインテグレーションフローはfromチャネルに登録されていませんか?

例外「メイン」 org.springframework.messaging.MessageDeliveryException:Dispatcherは、チャネル「application.inbox」の 何の加入者を持っていません;ネストされた例外は org.springframework.integration.MessageDispatchingExceptionです: ディスパッチャには、加入者、私が間違ってつもり

を持っていませんか?定義されたフローは受信ボックスチャネルへのサブスクリプションを作成しませんか?

import org.springframework.boot.SpringApplication; 
import org.springframework.context.ConfigurableApplicationContext; 
import org.springframework.context.annotation.Bean; 
import org.springframework.context.annotation.ComponentScan; 
import org.springframework.context.annotation.Configuration; 
import org.springframework.integration.annotation.IntegrationComponentScan; 
import org.springframework.integration.annotation.MessagingGateway; 
import org.springframework.integration.channel.DirectChannel; 
import org.springframework.integration.dsl.IntegrationFlow; 
import org.springframework.integration.dsl.IntegrationFlows; 
import org.springframework.messaging.MessageChannel; 

@Configuration 
@ComponentScan 
@IntegrationComponentScan 
public class App { 

    public static void main(String[] args) { 

     try (ConfigurableApplicationContext ctx = SpringApplication.run(App.class, args)) { 

      final Gateway gateway = ctx.getBean(Gateway.class); 
      final String rs = gateway.send("hullo"); 
      System.out.println(rs); 

     } 

    } 

    private static final String INBOX = "inbox"; 

    @MessagingGateway(defaultRequestChannel = INBOX) 
    public interface Gateway { 
     String send(String msg); 
    } 

    @Bean 
    public IntegrationFlow flow() { 
     return IntegrationFlows.from(INBOX) 
       .transform(p -> "world") 
       .get(); 
    } 

    @Bean(name = INBOX) 
    public MessageChannel inbox() { 
     return new DirectChannel(); 
    } 

} 

答えて

3

は、メインプレーヤーを見逃しているように見える - @EnableIntegraion

春の統合インフラ豆(Javadocを参照してください)の登録を可能にするために、@EnableIntegration注釈が導入された、バージョン4.0以降。この注釈は、Java &アノテーション設定のみが使用されている場合に必要です。 Springブートおよび/またはSpring統合メッセージングによる注釈のサポートおよびSpring統合XML統合構成のないJava DSL。

http://docs.spring.io/spring-integration/docs/4.3.0.BUILD-SNAPSHOT/reference/html/overview.html#configuration-enable-integration

+0

私は特にTFMへのリンクに感謝! – djeikyb

関連する問題