我有一个我想要使用的自定义Spring XD源:
package com.my.springproject;
import org.springframework.integration.annotation.InboundChannelAdapter;
import org.springframework.integration.annotation.Poller;
public class MySource
{
@InboundChannelAdapter(value = "output",
poller = @Poller(fixedDelay = "5000", maxMessagesPerPoll = "1"))
public String next() {
return "foo";
}
}
现在的问题是,我如何在ModuleConfiguration.java中注册它,以便Spring XD将其识别为有效的源?到目前为止我有这个,但Source从未记录任何内容。
我的ModuleConfiguration如下所示:
package com.my.springproject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.messaging.MessageChannel;
@Configuration
@EnableIntegration
@ComponentScan( value = { "com.my.springproject" } )
public class ModuleConfiguration {
@Bean
MessageChannel output() {
return new DirectChannel();
}
@Bean
MySource source() {
return new MySource();
}
}
答案 0 :(得分:1)
您必须使用MySource
或仅使用@MessageEndpoint
标记@Component
。
看起来我们在那里过度了一点,在MessagingAnnotationPostProcessor
:
if (AnnotationUtils.findAnnotation(beanClass, Component.class) == null) {
// we only post-process stereotype components
return bean;
}
看起来有点奇怪,不要仅在@Bean
上扫描消息传递注释。
随意提出有关此问题的JIRA(Lookups that span relationships)问题!