Reputation: 55
I have a custom Spring XD source that I want to use:
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";
}
}
The question now is, how do I register this in my ModuleConfiguration.java, so that Spring XD will recognize it as a valid source? So far I have this, but the Source never logs anything.
My ModuleConfiguration looks like this:
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();
}
}
Upvotes: 2
Views: 594
Reputation: 121272
You have to mark your MySource
with the @MessageEndpoint
, or just with the @Component
.
Looks like we overdid there a bit and have this logic in the MessagingAnnotationPostProcessor
:
if (AnnotationUtils.findAnnotation(beanClass, Component.class) == null) {
// we only post-process stereotype components
return bean;
}
Looks like this is a bit weird do not scan Messaging Annotations on just @Bean
.
Feel free to raise a JIRA(https://jira.spring.io/browse/INT) issue on the matter!
Upvotes: 1