Add support for @EnableModule, @Input and @Output
* enable the component model based on @EnableModule with existing functionality * any field annotated with Input/Output will trigger the creation and injection of a channel * update examples and tests * update README
This commit is contained in:
committed by
Mark Fisher
parent
2fa5724cee
commit
23e4cbc7ac
@@ -20,6 +20,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.streams.annotation.EnableModule;
|
||||
import org.springframework.cloud.streams.annotation.Output;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.annotation.InboundChannelAdapter;
|
||||
@@ -31,21 +33,20 @@ import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
@Configuration
|
||||
@EnableModule
|
||||
public class ModuleDefinition {
|
||||
|
||||
@Value("${format}")
|
||||
private String format;
|
||||
|
||||
@Bean
|
||||
public MessageChannel output() {
|
||||
return new DirectChannel();
|
||||
}
|
||||
@Output
|
||||
public MessageChannel output;
|
||||
|
||||
@Bean
|
||||
@InboundChannelAdapter(value = "output", autoStartup = "false", poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
|
||||
@InboundChannelAdapter(value = "output", autoStartup = "false",
|
||||
poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
|
||||
public MessageSource<String> timerMessageSource() {
|
||||
return () -> new GenericMessage<>(new SimpleDateFormat(format).format(new Date()));
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ package demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.streams.EnableChannelBinding;
|
||||
import org.springframework.cloud.streams.annotation.EnableModule;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
import config.ModuleDefinition;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableChannelBinding
|
||||
@EnableModule
|
||||
@ComponentScan(basePackageClasses=ModuleDefinition.class)
|
||||
public class SourceApplication {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user