Java 如何为Spring XD配置Spring InboundChannelAdapter?
我有一个要使用的自定义Spring XD源:Java 如何为Spring XD配置Spring InboundChannelAdapter?,java,spring,spring-integration,spring-xd,Java,Spring,Spring Integration,Spring Xd,我有一个要使用的自定义Spring XD源: package com.my.springproject; import org.springframework.integration.annotation.InboundChannelAdapter; import org.springframework.integration.annotation.Poller; public class MySource { @InboundChannelAda
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中注册它,以便SpringXD将其识别为有效的源代码?到目前为止,我有这个,但源从未记录任何东西
我的模块配置如下所示:
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();
}
}
您必须使用
@MessageEndpoint
标记您的MySource
,或者只使用@组件标记
看起来我们有点过头了,在MessagingAnnotationPostProcessor
中有这个逻辑:
if (AnnotationUtils.findAnnotation(beanClass, Component.class) == null) {
// we only post-process stereotype components
return bean;
}
看起来这有点奇怪,不要只在@Bean
上扫描消息注释
请随便就此事提出JIRA()问题