2016-04-03 20 views
2

Bana göre, bu sadece mümkün olan en basit yay entegrasyonu örneğidir. si4demo'dan öğrenmeye çalışıyorum. Bunu çalıştırdığınızda Ama bu durum almak: dizisindekiEntegrasyon akışı neden kanaldan abone olmaz?

İstisna "ana" org.springframework.messaging.MessageDeliveryException: Dispatcher kanalı 'application.inbox' için fazla abonesi .; Nerede yanlış gidiyorum Dispatcher hiçbir abonesi

sahiptir: iç içe özel org.springframework.integration.MessageDispatchingException nedir? Tanımlanan akış gelen kutusu kanalına bir abonelik oluşturmuyor mu?

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(); 
    } 

} 

cevap

3

ana oyuncu kaçırmış gibi görünüyor - @EnableIntegraion:

Bahar Entegrasyon altyapısı fasulye (javadocs bakınız) kaydını sağlamak için, @EnableIntegration açıklama tanıtıldı, sürüm 4.0 ile başlayarak. Bu açıklama sadece Java & Ek açıklama yapılandırması kullanıldığında gereklidir, örn. XML önyükleme yapılandırması olmadan Spring Boot ve/veya Spring Integration Messaging Annotation desteği ve Spring Integration Java DSL ile.

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

+0

i özellikle TFM'ye bağlantı takdir! – djeikyb